I am trying to geocode 2 addresses in a model using geocoder and I can\'t get gem to work as I want to. Here is the code that I am applying to my model:
clas
Rewrite
def function
...
end
as:
def update_coordinates
geocode
[latitude, longitude, latitude2, longitude2]
end
And also:
geocoded_by :destination_address, :latitude => :latitude2, :longitude => :longitude2
You also don't need :latitude => :lat, :longitude => :lon
here:
geocoded_by :source_address, ...
And finally, coordinates are fetched automatically after record is validated. So you could do without update_coordinates
(or function
, in your version) and arrange the view for show action like this:
<%= @sender.latitude %>
<%= @sender.longitude %>
<%= @sender.latitude2 %>
<%= @sender.longitude2 %>