I encountered the following error when I submit an empty address field.
Gmaps4rails::GeocodeInvalidQuery in LocationsController#create You must provide an address
My Model
class Location < ActiveRecord::Base
validates :address, :presence => true
acts_as_gmappable
def gmaps4rails_address
address
end
def gmaps4rails_infowindow
"<h4>#{name}</h4>" << "<h4>#{address}</h4>"
end
end
The question why it never validates the address field presence or not and directly throw error?
Fixed in 0.8.7
it will now normally add error to the address field.
Gmaps4rails already checks whether or not the address is empty or nil. It's part of the options described here.
You can, for instance, set your own validation message this way:
acts_as_gmappable :msg => "Errrrrrrror"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With