只是在玩 gem 'gmaps4rails' 但我收到以下路由错误
undefined local variable or method `acts_as_gmappable'
我执行了以下步骤: 1) 将以下内容添加到 Gemfile:gem 'gmaps4rails' 并捆绑 2)生成的脚手架Location 3) 将以下内容添加到我的模型中,location.rb 然后是 db:migrate
class Location < ActiveRecord::Base
attr_accessible :address, :latitude, :longitude
acts_as_gmappable
def gmaps4rails_address
address
end
end
5) 将我的根更改为以下内容并删除了旧的索引文件
root :to => 'locations#index'
6) 将以下内容添加到 aplication.html.erb 的正文中
<%= yield :scripts %>
好像在我安装的gem里面找不到方法?
我正在使用 gmaps4rails v2.0.3、ruby v1.9.3、rails 3.2.1
我在 stackoverflow 上查看了类似的主题并执行了一些简单的任务,例如重新启动服务器等,但仍然出现相同的错误。
@apneadiving 也许你能帮忙?
非常感谢
最佳答案
查看 gmaps4rails 的文档,从 2.* 版本开始,您不必添加 acts_as_gmappable 方法。 现在它使用地理编码器。 这是一个小tutorial ,这解释了它是如何工作的。
关于ruby - 'gmaps4rails' 未定义局部变量或方法 'acts_as_gmappable' rails 3.2.1 路由错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19753527/