【发布时间】:2016-09-01 07:34:58
【问题描述】:
我有这个正常工作的 SQL 查询:
UPDATE my_table SET geography = ST_SetSRID(ST_MakePoint(my_table.longitude, my_table.latitude), 4326)::geography;
但我想知道一种在 Ruby 方法中执行此操作的方法(用 lon/lat 数据填充我的地理类型列(lon/lat 是另外 2 个列)。
提前致谢。
【问题讨论】:
-
刚刚在 Ruby 中找到了一种方法,但我觉得它有点脏:
ActiveRecord::Base.connection.execute("UPDATE my_table SET geography = ST_SetSRID(ST_MakePoint(my_table.longitude, my_table.latitude), 4326)::geography")
标签: ruby-on-rails ruby database postgresql postgis