I successfully use the gmaps4rails gem on my local MySQL machine. However, when I deploy to PG on Heroku, I get the following error with respect to code that uses the gmaps4rails "near" function to find locations near the selected location:
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'
I suspect that this is because of something not being supported in this query in postgres, but the gem supposedly supports postgres. Any idea what's going on?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…