Repository navigation
DRY example
excid3 edited this page Sep 28, 2011
·
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', :check_process => :prevent_geocoding,
:address => "address", :normalized_address => "address",
:msg => "Sorry, not even Google could figure out where that is"
def prevent_geocoding
address.blank? || (!lat.blank? && !lng.blank?)
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.