我在本地 MySQL 机器上成功使用了 gmaps4rails gem。但是,当我在 Heroku 上部署到 PG 时,对于使用 gmaps4rails“near”函数查找所选位置附近的位置的代码,我收到以下错误:
2012-05-21T17:58:40+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR: operator does not exist: numeric - character varying
2012-05-21T17:58:40+00:00 app[web.1]: ^
2012-05-21T17:58:40+00:00 app[web.1]: LINE 1: ...8.755864232 * 2 * ASIN(SQRT(POWER(SIN((30.1926300 - venues.l...
2012-05-21T17:58:40+00:00 app[web.1]: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2012-05-21T17:58:40+00:00 app[web.1]: : SELECT venues.*, 3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((30.1926300 - venues.latitude) * PI() / 180 / 2), 2) + COS(30.1926300 * PI() / 180) * COS(venues.latitude * PI() / 180) * POWER(SIN((-85.8356740 - venues.longitude) * PI() / 180 / 2), 2) )) AS distance, CAST(DEGREES(ATAN2( RADIANS(longitude - -85.8356740), RADIANS(latitude - 30.1926300))) + 360 AS decimal) % 360 AS bearing FROM "venues" WHERE (3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((30.1926300 - venues.latitude) * PI() / 180 / 2), 2) + COS(30.1926300 * PI() / 180) * COS(venues.latitude * PI() / 180) * POWER(SIN((-85.8356740 - venues.longitude) * PI() / 180 / 2), 2) )) <= 5) ORDER BY distance LIMIT 5):
2012-05-21T17:58:40+00:00 app[web.1]: app/controllers/venues_controller.rb:22:in `show'
我怀疑这是因为 postgres 中的此查询不支持某些内容,但据说 gem 支持 postgres。知道发生了什么吗?