开发者

undefined local variable or method 'acts_as_gmappable'

I attempted to install the gmaps4rails gem.

I added gem 'gmaps4rails' to my Gemfile, and ran 'bundle install. It said that my bundle installed successfully. I can find "Using gmaps4rails (0.8.8)" with 'gem list'. I added the specified columns to my users table with rake db:migrate and added acts_as_gmappable and the gmaps4r开发者_Python百科ails_address method to my User model.

Visiting pages that involve the user model gives me "undefined local variable or method 'acts_as_gmappable'"error.

Is there something that I am missing?

For greater context, the code I am using is from the Rails 3 Tutorial.

OS X 10.6.6

ruby 1.8.7

rails 3.0.7

passenger 3.0.7


Restarting the server should resolve the problem :)


I had the same issue : undefined local variable or method 'acts_as_gmappable'

I just restarted the server and it error went away.


I was using Mongoid and had the same trouble.

In which 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


I think this may be helpful (similar issue):

rvm + rails3 + gmaps4rails - acts_as_gmappable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜