forked from apneadiving/Google-Maps-for-Rails
-
Notifications
You must be signed in to change notification settings - Fork 0
DRY example
conchulio edited this page Jul 31, 2012
·
8 revisions
Here is a great DRY piece of code suggested by Mircea Pricop https://github.com/mirceapricop
acts_as_gmappable :lat => 'lat', :lng => 'lng', :process_geocoding => :geocode?,
:address => "address", :normalized_address => "address",
:msg => "Sorry, not even Google could figure out where that is"
def geocode?
(!address.blank? && (lat.blank? || lng.blank?)) || address_changed?
end
The columns in his db are, lat, lng, address, gmaps.
He uses directly his db column to pass the address to the gem and overwrite the address provided with the one normalized by Google.