I try to build my rails env with postgis. The following is the extension of my db:
List of installed extensions
Name | Version | Schema | Description
------------------+---------+------------+---------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 2.1.3 | public | PostGIS geometry, geography, and raster spatial types and functions
postgis_topology | 2.1.3 | topology | PostGIS topology spatial types and functions
(3 rows)
And I also can see the " t.spatial "location", limit: {:srid=>0, :type=>"geometry"}" in my schema.rb after add column and migration the database.
While in the console and rb file, I can't access the postgis method like:
> e.location = ST_GeomFromText('POINT(121.04238 24.777656)', 4326)
NoMethodError: undefined method `ST_GeomFromText' for main:Object
from (irb):2
from /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/console.rb:90:in `start'
from /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/console.rb:9:in `start'
from /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:69:in `console'
from /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /usr/local/rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>'
Or in ruby file:
@data.location = ST_GeomFromText('POINT(' + params[:longitude] +' ' + params[:latitude] + ')', 4326)
get the server error:
NoMethodError (undefined method `ST_GeomFromText' for #<DataController:0x000000053ee388>):
I try some idea from internet, but can't figure it out.