This post is part of a series of 31 Rails 4 articles being released each day in December 2012.
By default, sessions in Rails are persisted to cookies in the browser. One of the limitations of using the cookie store for session data is its size cannot exceed 4KB.
In past versions of Rails, different storage mechanisms were added to the core framework to handle this limitation, such as the Active Record and Memcached session stores. However, one major issue with the Active Record session store is that it is not scalable. It puts an unnecessary load on your database. Once your application receives a large amount of traffic, the sessions database table is continuously bombarded with read/write operations.
As of Rails 4, the Active Record session store has be removed from the core framework and is now deprecated.
If your application is still dependent on an Active Record backed session store, you can use the activerecord-session_store gem.
To ensure a seamless transition, add
activerecord-session_store to your
# Gemfile gem 'activerecord-session_store'
The activerecord-session-store gem follows the new Rails 4 deprecation policy. This means that this gem will work in Rails 4, however there is no guaranteed support for versions of Rails 4.1 and higher.