views:

63

answers:

1

I am migrating an existing application from Rails 2 to Rails 3. In the old environment file, SqlSessionStore was set up with:

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:database_manager => SqlSessionStore)
SqlSessionStore.session_class = MysqlSession

When trying to start my application in Rails 3, I'm told:

DEPRECATION WARNING: config.action_controller.session= has been deprecated. Please use config.session_store(name, options) instead. (called from config/application.rb:35)
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing': uninitialized constant ActionController::CgiRequest (NameError)

Is there an easy way to translate this concept over to Rails 3, or do I need to revisit how sessions are handled?

+1  A: 

You want something like this in application.rb

module MyApp
  class Application < Rails::Application
    config.session_store :active_record_store

See the docs and questions here: http://apidock.com/rails/ActiveRecord/SessionStore

Kevin
I've taken a look at ActiveRecordStore, but I've read that it has performance issues, and that's why this application was using [SqlSessionStore](http://railsexpress.de/blog/articles/2005/12/19/roll-your-own-sql-session-store/). Have those performance issues improved in Rails 3, or is there a way to use SqlSessionStore with the new Rails?
jrdioko
ActiveRecordStore should work find on any but the largest of sites. If you run into performance problems you should use memcached for your sessions. Don't optimize early, sessions are most likely a negligible part of your request speed. That said - no, I can't find any mention of sqlsessionstore for rails3. Perhaps they've just baked it in, but I have no idea.
Kevin