Undefined local variable or method 'act_as_gmappable'

I tried installing gmaps4rails gem.

I added the gem 'gmaps4rails' to my Gemfile and ran the 'bundle install . It said that my package was installed successfully. I can find "Using gmaps4rails (0.8.8)" using 'gem list' . I added the specified columns to my users table using rake db:migrate and added the acts_as_gmappable and gmaps4rails_address to my User model.

Visited pages that include the user model give me the error "undefined local variable or method 'acts_as_gmappable'" .

Is there something I am missing?

For more context, the code I'm using is from the Rails 3 tutorial.

OS X 10.6.6
ruby 1.8.7
rails 3.0.7
passenger 3.0.7

+6
source share
4 answers

Restarting the server should fix the problem :)

+13
source

I had the same problem: undefined local variable or method 'act_as_gmappable'

I just restarted the server and the error went away.

+1
source

I used Mongoid and had the same problem.

In this case, make sure your model includes:

 include Gmaps4rails::ActsAsGmappable acts_as_gmappable :position => :location field :gmaps, :type => Boolean field :location, :type => Array def gmaps4rails_address #describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki "#{self.address}, #{self.city}, #{self.country}" end 
+1
source

I think this might be useful (similar problem):

rvm + rails3 + gmaps4rails - actions_as_gmappable

0
source

Source: https://habr.com/ru/post/890946/


All Articles