Company.find_by_sql("UPDATE companies SET location =
GeomFromText('POINT(35.211232 -111.613529)') where id = #{object.id}")
class SomeModel < ActiveRecord::Base
def update_geo(point)
res = connection.execute <<- END
update companies set location = GeoFromText('#{point}') where id =
#{self.id}
END
end
end
I implemented that code and the sql errors went away. However, it
still does not update the field.
Here is the code I used in the model:
def update_geo(point)
sql = "UPDATE title_companies set location =
PointFromText('POINT(#{point.lat} #{point.long})') WHERE
ID=#{self.id};"
self.connection.execute(sql)
end
It runs with no errors, execute returns nil (as documented). I have
tried with and without self.save, but with no effect. (GeomFromText ==
PointFromText)
If I insert the sql directly into the query browser, it works fine.
Am I missing something straightforward, like clearing the connection
or using transactions?