The query I'd like to run is:
我想运行的查询是:
SELECT zcta.geoid10, ST_AsGeoJSON(ST_simplify(zcta.geom,500)) FROM zcta WHERE zcta.geoid10 = '90210'
However in the Rails console when I enter this:
但是在Rails控制台当我输入这个:
testquery = "SELECT zcta.geoid10, ST_AsGeoJSON(ST_simplify(zcta.geom,500)) FROM zcta WHERE zcta.geoid10 = '90210'"
Zcta.find_by_sql testquery
I get the following returned:
我得到以下回复:
=> [#<Zcta >]
If I do a basic query asking for the result of any column I get the response I expect. This only happens with PostGIS functions. Any idea what to do?
如果我做一个基本的查询,询问任何列的结果,我都会得到预期的响应。这只发生在PostGIS函数中。知道怎么做吗?
1 个解决方案
#1
3
Alias the calculated column and you will get a method added to the returned objects.
为计算列别名,您将获得添加到返回对象的方法。
Zcta.
select("*, ST_AsGeoJSON(ST_simplify(geom,500)) as my_geo").
where(geoid10: '90210').each do |result|
puts result.my_geo
end
#1
3
Alias the calculated column and you will get a method added to the returned objects.
为计算列别名,您将获得添加到返回对象的方法。
Zcta.
select("*, ST_AsGeoJSON(ST_simplify(geom,500)) as my_geo").
where(geoid10: '90210').each do |result|
puts result.my_geo
end