Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

rails 4.0, rake db:sessions:create

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?

question from:https://stackoverflow.com/questions/17655744/rails-4-0-rake-dbsessionscreate

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...