2011-08-19 32 views
27

我正在嘗試使用此guide將twitter集成到設計中。我基本上採取所有的facebook的出現,並用twitter取代它。然而,當我與Twitter登錄,我收到以下錯誤:爲Twitter設計,Cookie溢出錯誤?

ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow): 

以下網址:

http://localhost:3000/users/auth/twitter/callback?oauth_token=something&oauth_verifier=blah 

有沒有什麼好的辦法來解決解決這個問題?

謝謝!

回答

73

問題出在session["devise.facebook_data"] = env["omniauth.auth"]。 Twitter的回覆包含一個非常大且不適合會話的extra部分。一種選擇是將env["omniauth.auth"].except("extra")存儲在會話中。

+5

爲了弄清楚我不需要「額外」部分,我用'raise request.env [「omniauth.auth」]。to_yaml' – dandrews

8

您可以打開會話的ActiveRecord存儲。 查找範圍配置/初始化/ 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 

軌之前創建遷移rails g session_migration和遷移它。

+1

是否存在任何不利的副作用? – courtsimas

+0

我相信只有當會話數據大於4K時,才應該使用活動記錄存儲,這比將其存儲在Cookie中要慢一些。 –

+0

一些開箱即用的導軌開源cms無法使用此更改,btw ... – courtsimas