Rails:尝试安装 gem 时出现错误消息

发布于 2025-01-05 05:21:38 字数 5524 浏览 0 评论 0原文

我正在尝试安装一个名为 Forem 的(很棒的)Ruby gem https://github.com/radar/forem 它给了我 WillPaginate 模块的错误。我假设 Forem 使用 will_paginate gem,即使我在它的 Gemfile 中没有看到它

这个 Forem gem(这是一个论坛应用程序)通常对我有用,但这次我将它与另一个(很棒的)gem Enki(用于博客)结合起来它还使用 will_paginate https://github.com/xaviershay/enki/blob/master/Gemfile。 Enki 通常在 3.0 应用程序上运行,但我进行了 3.1 更新,因此它至少在这方面应该与 Forem 兼容,Forem 也是一个 3.1 应用程序。

这是当我尝试使用此命令安装 Forem 时收到的错误消息

 rails g forem:install

有人知道我如何尝试修复此问题吗?

错误

   .rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:5:in `alias_method': undefined method `per_page' for module `WillPaginate::ActiveRecord::RelationMethods' (NameError)
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:5:in `<module:RelationMethods>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:4:in `<module:ActiveRecord>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:3:in `<module:WillPaginate>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:2:in `<top (required)>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/engine.rb:555:in `each'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/engine.rb:555:in `block in <class:Engine>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /Users/mm/Sites/enki31/config/environment.rb:5:in `<top (required)>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/application.rb:83:in `require_environment!'
        from /Users/mmell/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/commands.rb:22:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

更新

Config/initializers/will_paginate.rb

此代码是Forem gem的一部分https://github.com/radar/forem/blob/master/config/initializers/will_paginate.rb,

if defined?(WillPaginate)
  module WillPaginate
    module ActiveRecord
      module RelationMethods
        alias_method :per, :per_page
        alias_method :num_pages, :total_pages
      end
    end
  end
end

I'm trying to install a (great) Ruby gem called Forem https://github.com/radar/forem it's giving me an error for WillPaginate module. I assume Forem uses will_paginate gem even though I don't see it in its Gemfile

This Forem gem (which is a forum application) normally works for me but this time I'm combining it with another (great) gem Enki (for blogging) that also uses will_paginate https://github.com/xaviershay/enki/blob/master/Gemfile. Enki normally runs on a 3.0 application but I went through the 3.1 update so it should, at least in that respect, be compatible with Forem, which is also a 3.1 app.

This is the error message I'm getting when I try to install Forem with this commnad

 rails g forem:install

Anyone know how I might go about trying to fix this?

Error

   .rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:5:in `alias_method': undefined method `per_page' for module `WillPaginate::ActiveRecord::RelationMethods' (NameError)
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:5:in `<module:RelationMethods>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:4:in `<module:ActiveRecord>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:3:in `<module:WillPaginate>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/bundler/gems/forem-02eecd37cacc/config/initializers/will_paginate.rb:2:in `<top (required)>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/engine.rb:556:in `block (2 levels) in <class:Engine>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/engine.rb:555:in `each'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/engine.rb:555:in `block in <class:Engine>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /Users/mm/Sites/enki31/config/environment.rb:5:in `<top (required)>'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
        from /Users/mm/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/application.rb:83:in `require_environment!'
        from /Users/mmell/.rvm/gems/ruby-1.9.2-p290@devise311/gems/railties-3.1.3/lib/rails/commands.rb:22:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

Update

Config/initializers/will_paginate.rb

This code is part of the Forem gem https://github.com/radar/forem/blob/master/config/initializers/will_paginate.rb,

if defined?(WillPaginate)
  module WillPaginate
    module ActiveRecord
      module RelationMethods
        alias_method :per, :per_page
        alias_method :num_pages, :total_pages
      end
    end
  end
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文