欢迎来到cool的博客
7

Music box

Click to Start

点击头像播放音乐
新博客链接

bug:ActionDispatch::Cookies::CookieOverflow 使用Active Record Session Store bug2: undefined method silence logger

当出现这个错误的时候  ActionDispatch::Cookies::CookieOverflow       是因为rails   对于 cookie 的大小 < 4kb 

bug2 :   undefined method silence logger . 也是这个问题解决的。  如果删除了 bundle 重新安装需要 再次该这个gem.

解决方法

 /activerecord-session_store

A session store backed by an Active Record class. A default class is provided, but any object duck-typing to an Active Record Session class with text session_id and data attributes is sufficient.

Installation

Include this gem into your Gemfile:

gem 'activerecord-session_store'

Run the migration generator:

rails generate active_record:session_migration

Run the migration:

rake db:migrate

Then, set your session store in config/initializers/session_store.rb:

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

To avoid your sessions table expanding without limit as it will store expired and potentially sensitive session data, it is strongly recommended in production environments to schedule the db:sessions:trim rake task to run daily. Running bin/rake db:sessions:trim will delete all sessions that have not been updated in the last 30 days. The 30 days cutoff can be changed using the SESSION_DAYS_TRIM_THRESHOLD environment variable.

 

对于使用过 log4r 的rails项目,还得修改 gem env 下的文件:gems/activerecord-session_store-1.1.0/lib/action_dispatch/session/active_record_store.rb

144       def logger
145         #ActiveRecord::Base.logger ||
146         ActiveRecord::SessionStore::NilLogger
147       end

把上面145行的代码注释掉, 重启ok.

返回列表