tkwidmer/refugerestrooms — pull request #113 by backspace (2014-04-09 01:28:12+00:00)
Title: Delegate guess to geocoder

I noticed that guessing locations in Canada wasn’t working because the code in `formsubmit.js` was making incorrect assumptions about what format the geocoding results were in. (Anyone can override their browser’s reported location to test this out, whether [with Chrome](https://developers.google.com/chrome-developer-tools/docs/mobile-emulation?hl=ja#device-geolocation-overrides) or the Javascript hack like I use in `features/support/locations.rb`. When I was in Vancouver, the city was incorrectly marked as Greater Vancouver, and the country stayed United States.

Rather than work on a more accurate Javascript solution, I’m delegating to the Ruby-based `geocoder` gem, which determines the address from the latitude and longitude. Then Rails renders the new restroom form with the fields filled in and it’s inserted with Javascript.