40

Rails 3.1 suggests running

rails generate session_migration

However this generates the exact same migration as

rake db:sessions:create

but none of the commands are recognized by my setup using rails 4.0

errors are :

Could not find generator session_migration.

and

Don't know how to build task 'db:sessions:create'

respectively.

I have run:

gem install 'activerecord-session_store'

How do I make it work so that i can store a shopping cart bigger than 4kb?

1
  • 4
    People who find the answer helpful should also upvote the question. Mar 7, 2014 at 18:22

1 Answer 1

60

The ActiveRecord session store has been extracted out of Rails into it's own gem as part of Rails move towards better modularity. You need to include the gem as shown below in your Gemfile to get access to the rake task and related functionality.

gem 'activerecord-session_store', github: 'rails/activerecord-session_store'

See the README of the gem linked above for more instructions, but you still need run the following command after installing the gem

rails generate active_record:session_migration

and after that you need to modify the config/initializers/session_store.rb to look like something like this

MyApp::Application.config.session_store :active_record_store, :key => '_Application_session'

or

Rails.application.config.session_store :active_record_store, :key => '_Application_session'

depending on your Rails version.

3
  • I try this but "Could not find generator active_record:session_migration" Oct 3, 2013 at 15:23
  • 2
    After updating gemfile, try to "bundle install" in console
    – justi
    Nov 1, 2013 at 21:34
  • You may need to run "bundle exec rails generate active_record:session_migration" Mar 7, 2014 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.