17 November 2008

Invalid Google Maps API key

Today, it took me 1 hour to find the reason why my google map was not showing in production env whereas everything was fine in development env. Needless to say I have a "view" spec + a selenium acceptance test which pass.

Google Maps API has only one error message for this kind of problem: "The Google Maps API key used on this web site was registered for a different web site. You can generate a new key for this web site at http://code.google.com/apis/maps/. "

Therefore, I started looking at the wrong place and changed the key set up for the "production" environment in the RAILS_ROOT + '/config/gmaps_api_key.yml many times without any success ...

Finally, I ended up looking at the source of the page and it appeared that the key parameter was empty!

  <script src="http://maps.google.com/maps?file=api&v=2.x&key=&hl=" type="text/javascript">