【问题标题】:Geokit undefined method `acts_as_mappable' railsGeokit 未定义方法 `acts_as_mappable' rails
【发布时间】:2015-05-16 01:27:20
【问题描述】:

我在本地计算机上的 Web 应用程序中使用了 geokit-rails gem,我按照他们的 github 存储库中的步骤操作,它在我的本地计算机上完美运行,但是一旦我在 openshift 远程服务器上部署了我的应用程序。它似乎不起作用。 openshift ruby​​.log 文件给出以下错误

[2015-05-15 21:10:52.1608 54455/7fec5b5fe700 代理/HelperAgent/RequestHandler.h:1971]:[客户端 20] 无法签出会话。启动 Web 应用程序时发生错误。 错误页面: 未定义的方法acts_as_mappable' for Group (call 'Group.connection' to establish a connection):Class (NoMethodError) /var/lib/openshift/555682cde0b8cd2874000091/app-root/runtime/repo/vendor/bundle/ruby/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:inmethod_missing' /var/lib/openshift/555682cde0b8cd2874000091/app-root/runtime/repo/app/models/group.rb:2:in `'

我确定我添加了 宝石'地理编码器' 宝石'geokit-rails' 宝石'gmaps4rails' 到我的gemfile,但问题仍然存在。我从我的应用程序中删除了对该方法的所有与 geokit 相关的代码的调用,它工作正常,所以问题一定出在其中。我关注了这个链接 Rails 3.1.0, geokit, with error acts_as_mappable 和这个链接 Geokit in Ruby on Rails, problem with acts_as_mappable 但它没有解决任何问题。

我使用的是 Rails 4.2.1

提前致谢

【问题讨论】:

  • geokit-rails 有什么作用?我在我的应用程序中使用地图,我只有 gem 'geocoder' 和 gem 'gmaps4rails'。
  • 这是我用的demo——我记得在做教程的时候使用acts_as_mappable,后来发现已经被贬值了。 youtube.com/watch?v=R0l-7en3dUw&spfreload=10
  • 我认为 OpenShift Online 目前不支持 rails 4.2(您使用的是什么版本的 ruby​​?)可能与您的错误有关。当您使用 git push 部署应用程序时,您是否遇到任何其他错误?
  • 不成功了
  • 我在尝试从 geokit-rails3 升级旧网站时收到此错误。当我需要 geokit-rails 时,我会不小心将其替换为 Gemfile 中的 geokit

标签: ruby-on-rails openshift geokit


【解决方案1】:

您应该通过 ctrl+c 重新启动您的 rails 应用程序,或者您应该再次退出 rails 控制台和 rails 控制台。

例如

Location.class
NameError: undefined local variable or method `acts_as_mappable' for Location (call 'Location.connection' to establish a connection):Class
    from /Users/caiqinghua/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
    from /Users/caiqinghua/weishop/app/models/location.rb:11:in `<class:Location>'
    from /Users/caiqinghua/weishop/app/models/location.rb:10:in `<top (required)>'

2.2.1 :018 >   exit
caiqinghua@qinghuadeMacBook-Pro:~/location(set-shop-location|✚1…) % rails c                                                                              (set-shop-location00)
Loading development environment (Rails 4.2.1)
2.2.1 :001 > Location.class
 => Class

【讨论】:

    【解决方案2】:

    当使用Spring时,你应该在重试之前停止它:

    $ spring stop
    Spring stopped.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多