rails 4.0, rake db:sessions:create [英] rails 4.0, rake db:sessions:create
问题描述
Rails 3.1 建议运行
Rails 3.1 suggests running
rails generate session_migration
然而,这会产生与
rake db:sessions:create
但是我使用 rails 4.0 的设置无法识别任何命令
but none of the commands are recognized by my setup using rails 4.0
错误是:
找不到生成器 session_migration.
Could not find generator session_migration.
和
不知道如何构建任务 'db:sessions:create'
Don't know how to build task 'db:sessions:create'
分别.
我已经跑了:
宝石安装'activerecord-session_store'
gem install 'activerecord-session_store'
如何使它工作,以便我可以存储大于 4kb 的购物车?
How do I make it work so that i can store a shopping cart bigger than 4kb?
推荐答案
ActiveRecord 会话存储已从 Rails 中提取到它自己的 gem 中,这是 Rails 朝着更好的模块化方向发展的一部分.您需要在 Gemfile
中包含如下所示的 gem 才能访问 rake
任务和相关功能.
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'
- 宝石
- 发生更改的 Rails 提交
- 一些解释
查看上面链接的 gem 的 README 以获得更多说明,但安装 gem 后仍然需要运行以下命令
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
然后你需要修改 config/initializers/session_store.rb 看起来像这样
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'
或
Rails.application.config.session_store :active_record_store, :key => '_Application_session'
取决于您的 Rails 版本.
depending on your Rails version.
这篇关于rails 4.0, rake db:sessions:create的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!