2

Recently I deployed my application on Heroku. I'm using Geokit to search events, based on user's location.

@events = Event.all(:origin => [@location.lat, @location.lng], :within => 5, :conditions => ["end_date >= ?", Date.today], :select => "id, created_at, user_id, location, description, permalink, title", :order => "created_at DESC")

The above statement is working fine in my local system with mysql database.

But I'm getting error while executing same stmt on Heroku. Please check the below error I'm facing on Heroku.

ActiveRecord::StatementInvalid (PGError: ERROR: function radians(character varying) does not exist 2011-03-20T00:52:23-07:00 app[web.1]: LINE 2: ...,COS(0.303256183987648)*COS(1.36963671754269)*COS(RADIANS(fr... 2011-03-20T00:52:23-07:00 app[web.1]: ^ 2011-03-20T00:52:23-07:00 app[web.1]: HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Any help would be greatly appreciated.

Thanks, Kalyan.

kals
  • 200
  • 3
  • 15

1 Answers1

6

As a heads-up, Heroku uses Postgres as the only SQL database backend: http://devcenter.heroku.com/articles/database

Therefore, your problem is related to these two Q&A:

Why does Postgresql fail with Geokit like this?

Rails: Converting from MySQL to PostGres breaks Geokit Distance Calculations?

In your case, you should add a database migration and change "lat" and "lng" in your location model from "string" (or "text") to "float", and then Geokit should work fine with Postgres and Heroku respectively.

Community
  • 1
  • 1
juwalter
  • 11,472
  • 5
  • 19
  • 18