开发者

Two address in the model

开发者 https://www.devze.com 2023-03-26 13:13 出处:网络
I have a model with two address in it.开发者_Go百科 It\'s possible to use gmaps4rails to geocode the two address ? How can I configure it ?

I have a model with two address in it.开发者_Go百科 It's possible to use gmaps4rails to geocode the two address ? How can I configure it ?

Thanks


It's definitely possible:

  • configure a standard one

  • use the following in a before_save:

    Gmaps4rails.geocode(second_address)

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


I highly recommend using Ruby Geocoder for this job! Why?

  1. It has multiple backends built-in.
  2. Integrates very well into Rails.
  3. Provides great methods like nearbys or distance_to.
  4. Has a great RailsCast about it.
  5. And no, I'm not advertising it - I'm only a happy user ;)
0

精彩评论

暂无评论...
验证码 换一张
取 消