Rails 4.0, rake db: sessions: create

Rails 3.1 suggests launching

rails generate session_migration 

However, this gives rise to the same movement as

 rake db:sessions:create 

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

:

Could not find session_migration generator.

and

I do not know how to build the task 'db: sessions: create'

respectively.

I ran:

gem install 'activerecord-session_store'

How do I get it to work so that I can store the cart more than 4kb?

+37
ruby-on-rails session
Jul 15 '13 at 13:44
source share
1 answer

The ActiveRecord session store was extracted from Rails into its own stone, as part of the Rails moves toward greater modularity. You need to include the gem as shown below in the Gemfile to gain access to the rake task and its 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 to run the following command after installing gem

 rails generate active_record:session_migration 

and after that you need to change config / initializers / session_store.rb to look 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 the version of Rails.

+58
Jul 15 '13 at 14:03
source share



All Articles