我正在尝试安装一个名为Forem https://github.com/radar/forem的(伟大的)Ruby gem,它为WillPaginate模块提供了一个错误。我假设Forem使用了will_paginate gem,即使我在Gemfile中没有看到它
这个Forem gem(这是一个论坛应用程序)通常适合我,但这次我将它与另一个(伟大的)宝石Enki(用于博客)结合使用,它也使用了will_paginate https://github.com/xaviershay/enki/blob/master/Gemfile。 Enki通常在3.0应用程序上运行,但我经历了3.1更新,所以至少在这方面,它应该与Forem兼容,这也是一个3.1应用程序。
这是我尝试使用此commnad安装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