Repository navigation
DRY example
dmahlow edited this page Jul 1, 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.