1

I am runnning a rails 2 project with the following gems, georuby, spatial_adapter. And Postgres db as backend. But I am facing this error. I tired installing postgis also but still get this. Any ideas what i should try. This is a rails 2.3 project ,so is it some version requirements i am missing. The statement seems to be correct and i tied looking it up too. Please help.

[root@localhost webapp]# rake db:migrate 
(in /root/mysite/webapp)
==  CreatePlaces: migrating ===================================================
-- create_table(:places, {:id=>false})
   -> 0.0030s
-- execute("alter table places add primary key (id)")
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "places_pkey" for table "places"
   -> 0.1144s
-- execute("select AddGeometryColumn('public', 'places', 'point_geometry', 4326, 'POINT', 3)")
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR:  function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist
LINE 1: select AddGeometryColumn('public', 'places', 'point_geometry...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
: select AddGeometryColumn('public', 'places', 'point_geometry', 4326, 'POINT', 3)

Thanks

hungry fish
  • 188
  • 1
  • 3
  • 12
  • I think your problem is in your installation of PostgreSQL/PostGis, not rails/ruby related. – shingara Feb 17 '12 at 09:40
  • yup I also felt that but could you confirm if the syntax is correct. Also suggest which version of postgres and/or postgis I may require. I am currently using gr 8.4 and postgis 1.5.3 on a fedora box. – hungry fish Feb 17 '12 at 10:21
  • I had not linked post gis with postgres. Thus was facing this issue. Follow the steps on the postgis site to link both first and create your db first. – hungry fish Feb 17 '12 at 13:02
  • the sintax is correct, what distribution of linux do you have? – Paco Valdez Feb 17 '12 at 17:46

1 Answers1

2

I had not linked post gis with postgres. Thus was facing this issue.

Follow the steps below and create your db first.

The first step in creating a PostGIS database is to create a simple PostgreSQL database.

createdb [yourdatabase]

Many of the PostGIS functions are written in the PL/pgSQL procedural language. As such, the next step to create a PostGIS database is to enable the PL/pgSQL language in your new database. This is accomplish by the command

createlang plpgsql [yourdatabase]

Now load the PostGIS object and function definitions into your database by loading the postgis.sql definitions file (located in [prefix]/share/contrib as specified during the configuration step).

psql -d [yourdatabase] -f postgis.sql

For a complete set of EPSG coordinate system definition identifiers, you can also load the spatial_ref_sys.sql definitions file and populate the spatial_ref_sys table. This will permit you to perform ST_Transform() operations on geometries.

psql -d [yourdatabase] -f spatial_ref_sys.sql

If you wish to add comments to the PostGIS functions, the final step is to load the postgis_comments.sql into your spatial database. The comments can be viewed by simply typing \dd [function_name] from a psql terminal window.

psql -d [yourdatabase] -f postgis_comments.sql
hungry fish
  • 188
  • 1
  • 3
  • 12