Tuesday, 13 August 2013

activerecord (rails) migration -- set option values for a column

activerecord (rails) migration -- set option values for a column

I'm using the rgeo gem in conjunction with the
activerecord-postgis-adapter gem for some columns, and I'm wanting the
change an option for an existing column
Allow me to show it this way, in the schema.rb file, currently this is the
line recording the column
t.spatial "shape", :limit => {:srid=>0, :type=>"multi_polygon"}
So this column has some special metatag options recognized by postgis.
I want to set the default srid of these :shape columns from 0 to 4326. I'd
either like to do this with a migration, or even better, to be able to set
the values for these points individually. Currently, I haven't located a
setter method in the RGeo documentation for the :srid tag, only a reader.
So I'm thinking my best bet is a migration.
I've tried this:
change_column :parcels, :shape, :srid, 4326
But got this error:
== AddSridOptToShapes: migrating
=============================================
-- change_column(:zones, :shape, :srid, 4326)
rake aborted!
An error has occurred, this and all later migrations canceled:
can't convert Symbol into Integer
I know that its possible to solve this problem by executing a string of
SQL, but am hoping active record provides a way as well

No comments:

Post a Comment