我正在将Rails 2应用程序升级到Rails 3,当我执行rails console
时它会抛出这个:
$ rails c production
/usr/lib/ruby/gems/1.8/gems/will_paginate-2.3.12/lib/will_paginate.rb:39:in `enable_activerecord': undefined method `returning' for WillPaginate:Module (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/will_paginate-2.3.12/lib/will_paginate.rb:88
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
from /home/neoriddle/proyectos/interkids/config/application.rb:7
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:21:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:21
from script/rails:6:in `require'
from script/rails:6
我该如何解决这个问题?
答案 0 :(得分:3)
更新will_paginate gem。
方法#returning
已弃用,方法#tap
。看起来你正在使用的旧版本的will_paginate gem仍然使用这种弃用的方法。
答案 1 :(得分:0)
是的,那是真的。
我的详细信息......
我改变了Gemfile
这一行:
gem 'will_paginate', '2.3.12'
这一行:
gem 'will_paginate', '>=3.0.pre'
然后我用这个更新Gemfile.lock
:
bundle update will_paginate
我明白了:
$ bundle update will_paginate
Fetching source index for http://rubygems.org/
...
Installing will_paginate (3.0.2)
Updating .gem files in vendor/cache
* will_paginate-3.0.2.gem
Removing outdated .gem files from vendor/cache
* will_paginate-2.3.12.gem
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
并且此错误已解决。