alexreisner / geocoder

Complete Ruby geocoding solution.
http://www.rubygeocoder.com
MIT License
6.35k stars 1.19k forks source link

Every Request (Almost) Always Raising Query Limit Error #1346

Closed mjohnson324 closed 6 years ago

mjohnson324 commented 6 years ago

Recently I've been seeing "Google API error: over query limit." a lot. With only a few exceptions I raise this error in my rails app regardless of the number of queries that have already been fired and I don't know how to fix this.

Context

The app simulates ZocDoc and can be used to search for doctors. Fake doctors are added via seeding for demoing the app. Part of this involves geocoding their addresses via the following lines in the Doctor model:

geocoded_by :location, latitude: :lat, longitude: :lng
after_validation :geocode
attr_accessor :location

Expected behavior

I run this line and expect geocoding to be successful:

doc_hibbert = Doctor.create!(location: '51 W 51st St, New York, NY', address: '51 W 51st St, New York, NY' first_name: 'Julius', last_name: 'Hibbert', education: 'Johns Hopkins University School of Medicine', degree: 'MD', address: '51 W 51st St, New York, NY')

Actual behavior

With few exceptions I instead raise 'Google API error: over query limit.'

Steps to reproduce

Geocode an object. I also get the same error if I attempt something like this in the rails console:

Doctor.first.update(location: Doctor.first.address)

That's just an example of how I tried manually geocoding one doctor afterwards, and how I was updating doctors when I encountered the same error because of rate limits. The update failed due to the error but the commit was successful.

Environment info

alexreisner commented 6 years ago

Closing, because this sounds like it has to do with your environment, not the gem, but if you post your Geocoder.configure block I might be able to suggest something. Are you using an API key and a paid Google API account? (This is required as of a few months ago.)

mjohnson324 commented 6 years ago

Thank you for the response. I don't have an API key, and until yesterday I hadn't set up a paid account on Google Maps. I don't intend for the site to be anything beyond a demo so I'll need to evaluate whether to stick with Google Maps.

Update:

got it working smoothly once keys and billing were set up, and the keys are encrypted.

Also just wanted to say this is an amazing project that's saved me a lot of time. Seriously, thank you.

viktorsmari commented 6 years ago

Came here because of the same problem. Maybe information about Google now requiring billing etc. should be added to the readme for a while?