Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

Google-Maps-for-Rails gem, Force Geocoding of Model


How do I force Google-Maps-for-Rails gem to geocode a model? I dont' want to re-geocode every member, just some.

Along those lines, once a model member has been geocoded and the lon/lat stored in the db, how do I clear that so it re-geocodes?

Could be the same answer for both questions, I don't know.


Solution

  • Your question raised a problem in the gem: it geocoded after each save, not checking the boolean reference. It's fixed now in 0.4.1

    By default

    • Geocoding is made as part of the save process.
    • if the boolean gmaps == true, then geocoding is skipped
    • else the geocoding is done

    You can configure it the way you want.

    BTW, you could even use the geocoding function:

    Gmaps4rails.geocode('your address')
    

    And saves directly the values you want.

    See doc here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Methods