I’m getting the following error when I try to create a new venue that is location aware.
ActiveRecord::StatementInvalid: PG::Error: ERROR: new row for relation "venues" violates check constraint "enforce_srid_latlon"
This is the method I follow to recreate the error.
v = Venue.create(:latlon => "POINT (43.245332 -85.4352332)")
v.save
I did notice that in my migrations, I did not set the :geographic => true property for t.point :latlon. Could that be what’s causing my problems? If so, how do I set that flag to true on a column that already contains data?
The simplest way to set your SRID is to prefix the WKT into EWKT (extended well-known text):
I’m using SRID=4326, since it looks like you have WGS84 latitude/longitude coordinates, which is typical.