Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

gmaps4rails automatic geocoding not working


I have a simple app running Rails3 & the gmaps4rails gem.
I have the map displaying successfully.

But, when I create a new User, the lat/long is not automatically generated like in the screencast. What am I missing?

Here is my model code:

class Merchant < ActiveRecord::Base  
acts_as_gmappable  
 def gmaps4rails_address  
  "#{self.address}, #{self.zip} #{self.city}, #  {self.country}"  
 end  
end

I also can't enter in an address as simply "City, State". I have to put in a complete address or I get an error.


Solution

  • There will not be any issue not using the example I provide in the wiki:

    def gmaps4rails_address
      "#{self.address}, #{self.zip} #{self.city}, # {self.country}"  
    end
    

    This is just supposed to tell that you can customize it as you need.

    So yes, it could simply be:

    def gmaps4rails_address
      self.address 
    end