Slinky
Slinky

Reputation: 5832

Migrating to Rails 3.2 - Undefined method 'session=' for ActionController::Base:Class

I migrated an old Ruby (1.8.7) and Rails (2.2.2) application to Ruby (1.9.3) and Rails (3.2.12) following all of these excellent references:

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

I am able to start up the app's Rails server but when I access the app via the browser, and then BLAMMO! I get a server error:

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

When I grep -r for "session =" I get:

/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 = {

According to a Google search for that error, it's an old issue from Rails 2 so I'm wondering If I missed something in the migration process or if this is something else. Thanks

Here is my terminal session activity:

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

Then, I hit the application from a browser and:

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

Upvotes: 2

Views: 2724

Answers (1)

keithepley
keithepley

Reputation: 4802

Try using config.session_store instead. You'll have to specify the store type, most likely :cookie_store. Here's an example of what it will look like in your application.rb

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

Whatever options you had after the session= will go inside that hash there.

Upvotes: 6

Related Questions