设计Twitter,Cookie溢出错误?

dis*_*dng 27 twitter ruby-on-rails devise

我正在尝试使用本指南将twitter集成到设计中.我基本上把所有出现的facebook都用twitter取而代之.但是,当我使用Twitter登录时,我收到以下错误:

ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow):
Run Code Online (Sandbox Code Playgroud)

在以下网址:

http://localhost:3000/users/auth/twitter/callback?oauth_token=something&oauth_verifier=blah
Run Code Online (Sandbox Code Playgroud)

有什么好方法可以解决这个问题吗?

谢谢!

Lam*_*bda 73

问题在于session["devise.facebook_data"] = env["omniauth.auth"].Twitter的回复包含一个extra非常大的部分,不适合会话.一种选择是env["omniauth.auth"].except("extra")在会话中存储.

  • 为了弄清楚我不需要"额外"部分,我使用了`raise request.env ["omniauth.auth"].to_yaml` (5认同)

Mik*_*kin 7

您可以打开ActiveRecord商店进行会话.查看config/initializers/session_store.rb

注释掉有关使用的行:cookie_store

取消注释底部使用的行:active_record_store

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
MyApp::Application.config.session_store :active_record_store
Run Code Online (Sandbox Code Playgroud)

在rails之前创建迁移rails g session_migration并迁移它.