迁移到Rails 3.2 - 未定义的方法'session ='for ActionController :: Base:Class

时间:2013-02-19 14:49:00

标签: ruby ruby-on-rails-3

我将旧的Ruby(1.8.7)和Rails(2.2.2)应用程序迁移到Ruby(1.9.3)和Rails(3.2.12),并遵循所有这些优秀的参考资料:

Rails Upgrade Script
Rails 3 Migration Blog
Booting the Rails 3 App

我可以启动应用程序的Rails服务器,但是当我通过浏览器访问应用程序时,然后是BLAMMO!我收到服务器错误:

!!处理请求时出现意外错误:未定义方法`session ='for ActionController :: Base:Class

当我grep -r为“session =”时,我得到:

/var/www/vendor_sandbox/config/application.rb:    config.action_controller.session = {
/var/www/vendor_sandbox/config/environment.rb.rails2:  config.action_controller.session = {
/var/www/vendor_sandbox/destroy/config/environment.rb:  config.action_controller.session = {
/var/www/vendor_sandbox/generate/config/environment.rb:  config.action_controller.session = {

根据Google搜索该错误,这是Rails 2中的一个老问题,所以我想知道如果我在迁移过程中遗漏了某些内容,或者这是否是其他内容。感谢

这是我的终端会话活动:

root@partners:/var/www/vendor_sandbox# ruby -v
ruby 1.9.3p385 (2013-02-06 revision 39114) [i686-linux]
root@partners:/var/www/vendor_sandbox# rails --version
Rails 3.2.12
root@partners:/var/www/vendor_sandbox# rails s
=> Booting Thin
=> Rails 3.2.12 application starting in development on     http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

然后,我从浏览器点击了应用程序,然后:

!! Unexpected error while processing request: undefined method `session=' for ActionController::Base:Class

1 个答案:

答案 0 :(得分:6)

请尝试使用config.session_store。您必须指定商店类型,最有可能是:cookie_store。以下是application.rb

中的示例
config.session_store(:cookie_store, {:key => foo, :secret => bar})

session=之后你所拥有的任何选项都会进入那个哈希。