【问题标题】:'gmaps4rails' undefined local variable or method 'acts_as_gmappable' rails 3.2.1 routing error'gmaps4rails' 未定义的局部变量或方法 'acts_as_gmappable' rails 3.2.1 路由错误
【发布时间】:2013-11-03 13:35:44
【问题描述】:

只是在玩 gem 'gmaps4rails' 但我收到以下路由错误

undefined local variable or method `acts_as_gmappable'

我执行了以下步骤: 1) 将以下内容添加到 Gemfile:gem 'gmaps4rails' 并捆绑 2)生成的脚手架位置 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 也许你能帮忙?

非常感谢

【问题讨论】:

  • 使用ZeusSpring?
  • V2 不再提供acts_as_gmappable,请阅读github上的文档
  • 使用geocoder进行地理编码,gmaps4rails显示地图
  • 我做了一个视频教程,链接在github的repo上提供

标签: ruby ruby-on-rails-3 ruby-on-rails-3.2 gmaps4rails


【解决方案1】:

查看 gmaps4rails 的文档,因为 2.* 版本您不必添加acts_as_gmappable 方法。 现在它使用地理编码器。 这是一个小的tutorial,它解释了它是如何工作的。

【讨论】:

    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    • 2012-10-14
    • 1970-01-01
    相关资源
    最近更新 更多