Reputation: 39763
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
Upvotes: 1
Views: 422
Reputation: 39763
I solved this problem by simply creating a new column, and in my case, on for every projection I needed to use with a particular shapefile record
:proj_shape_0
:proj_shape_3361
:proj_shape_2264
etc where the number is the srid code
Upvotes: 0