I am using Ruby Geocoder with Rails. I have the following in my model:
class Location < ActiveRecord::Base
geocoded_by :locale
def locale
[city, state].compact.join(', ')
end
before_save :geocode #, :if => :address_changed?
end
I have a rake task that imports cities & states into the locations database. However, as it is running, it throws the following error constantly:
Google Geocoding API error: over query limit.
The Geocoder docs offer this option for the rake task to alleviate the problem:
rake geocode:all CLASS=YourModel SLEEP=0.25 BATCH=100
How would I put an option like that in the before_save
callback in my model?