I am using the geocoder gem for the first time in my rails app. My question is little generic. My rails app need to submit from and to address. When I look at the documentation provided in the github page, we have something like
rails generate migration AddLatitudeAndLongitudeToModel latitude:float longitude:float
rake db:migrate
Say supposing, my model name is Location which has two address fields : from_address and to_address then should I have latitudes and longitudes separately for from and to address? if I set geo_code
to both of these from and to addresses. ie, something like
In my Location model
geocoded_by :from_address,:to_address
And,
Model : Location
Location(from_address: string, to_address:string, from_address_latitude: float, to_address_longitude: float, to_address_latitude: float, to_address_longitude: float)
So in short, should I have a separate latitude and longitude fields for both of these address fields (ie, from_address and to_address)
or is it simply enough to have just latitude and longitude?
You should define latitude and longitude for both addresses, then the following should work:
geocoded_by :from_address,
latitude: :from_address_latitude,
longitude: :from_address_longitude
geocoded_by :to_address,
latitude: :to_address_latitude,
longitude: :to_address_longitude
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.