4

geocoder gem has stopped working solely in the production environment. It works perfect and as expected in development.

I am on Ubuntu 16.04 using ruby 2.3.1 and rails 4.2.6

When I run ModelName.near("zip_code", "radius") in development from the rails console, I am returned the associated rows as expected. When I run the same command in the server, it returns Google Geocoding API error: over query limit.

UPDATE

lat and long are not being saved in the production environment, but are being saved in development.

Ctpelnar1988
  • 1,235
  • 3
  • 15
  • 38
  • You have two options: 1. Sign up for pay-as-you-go with Google so you don't hit rate limits (see [here](https://developers.google.com/maps/documentation/geocoding/usage-limits)) 2. Cache lookups or otherwise optimize your app to hit the API less (see [here](https://stackoverflow.com/a/31618535/2981429)) – max pleaner Jun 15 '17 at 20:35
  • I definitely have not hit anywhere near the 2500 cap to need to upgrade to need to enable pay-as-you-go account. I am wondering why I am able to get the query to work in development, but failing in production with the `over query limit` error? Thanks for the references btw. – Ctpelnar1988 Jun 15 '17 at 20:41
  • I also put a `sleep(2)` to see if that would fix the problem, but still did not. – Ctpelnar1988 Jun 15 '17 at 20:42
  • did you manage to figure out the reason for this query limit? i'm experiencing a similar issue... – gitastic Nov 18 '17 at 13:53
  • No, this is still an open issue as I too am still experiencing problems. – Ctpelnar1988 Nov 18 '17 at 14:32

2 Answers2

0

I had a similar problem. Adding my google api key to config/initializers/geocoder.rb resolved my issue.

0

Adding a key for GeoCoder resolves this issue:

Create a file config/initializers/geocoder.rb and paste below code:

Geocoder.configure(
  api_key: 'YOUR_API_KEY'
)

You need to replace "YOUR_API_KEY" with a valid Google Geocoder API key.

Status codes are available at https://developers.google.com/maps/documentation/geocoding/intro#StatusCodes

Faisal Raza
  • 1,337
  • 1
  • 10
  • 16