apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

undefined method `gmaps' #41

Closed szymon-przybyl closed 13 years ago

szymon-przybyl commented 13 years ago

I've done everything like in how-to, and every time I try to register new user, i get the following error:

undefined method `gmaps' for #User:0xa3e0788

szymon-przybyl commented 13 years ago

oh, i've didn't add gmaps column :) in instruction there was "#not mandatory", so I thought it is not mandatory at all :)

apneadiving commented 13 years ago

:)

marqueymarc commented 13 years ago

I have this and can't find instructions which even mention it! please point me at the tutorial.

apneadiving commented 13 years ago

Isn't it the same problem as above: you didn't add the column in your db.

Notice this additional column is optional: you can decide to use a virtual attributes or even a method as a checker.

See example here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/DRY-example

marqueymarc commented 13 years ago

I'm unsure how this applies. According to the tutorial and instructions I saw, I have an address column in the db, and a gmaps4rails_address, this should be all I need? What am i missing?

class Location < ActiveRecord::Base attr_accessible :address, :latitude, :longitude acts_as_gmappable

def gmaps4rails_address address end end

apneadiving commented 13 years ago
add_column :users, :gmaps, :boolean #not mandatory, see wiki

https://github.com/apneadiving/Google-Maps-for-Rails/wiki/DRY-example

marqueymarc commented 13 years ago

thanks, apnea. somehow I don't see this in the wiki. where is it? not under the link you pointed me at.
I'td be great to have a complete page of setup instructions which was comprehensive and up to date. I also have problems with the install task for moving the .js files.

apneadiving commented 13 years ago

the basics are written on the very first page of the gem: https://github.com/apneadiving/Google-Maps-for-Rails

For some reason it's no more displayed correctly but it's still written :)

in 0.9.0 and 0.9.1, the generator doesn't work anymore, I'll fix it in the next version.

I'm finishing integration of other map providers such as openlayers which doesn't have the restrictions of google.

esromneb commented 11 years ago

If you want to avoid this error without updating your model, you can add the :checker option like this:

acts_as_gmappable :lat => "lat", :lng => "lon", :checker => "id"

This assumes that your model already has an "id" field