Put Sessions into Database with Rails

Adding sessions into the database is a great way to speed up your application, and it’s very easy to do in Rails 2.x. It can be done in the following, 3 easy, steps:

rake db:sessions:create

rake db:migrate

Now go into config/environment.rb and uncomment the following line:

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with 'rake db:sessions:create')
config.action_controller.session_store = :active_record_store

It’s is easy as that, now all of your sessions will be added to the database instead of files accessed at system level.

Cheers

Posted on August 30, 2008 at 4:33 pm

No Responses »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

(required)

(required)