![](/img/trans.png)
[英]ActionDispatch::Cookies::CookieOverflow but the cookie is small
[英]How to rescue_from ActionDispatch::Cookie::CookieOverflow?
首先,我讀到:
這不是我要面對的問題。
我正在與:
gem "rails", "~> 3.2.11"
和
ruby 1.9.3-p125
我正在嘗試處理搜索,當搜索太大時,出現此錯誤:
ActionDispatch::Cookies::CookieOverflow
我想在ApplicationController中搶救這個錯誤,但似乎對我不起作用:
rescue_from ActionDispatch::Cookies::CookieOverflow :with => :render_404
哪里:
def render_404
respond_to do |r|
r.html { render :template => "something/404", :status => 404}
r.all { render :nothing => true, :status => 404 }
end
true
end
任何幫助都會受到歡迎。
rescue_from ActionDispatch::Cookies::CookieOverflow :with => :render_404
根據文檔,您在參數中缺少逗號(,)
使用correc語法
rescue_from ActionDispatch::Cookies::CookieOverflow, with: :render_404
rescue_from接收一系列異常類或類名,以及帶有方法名的結尾:with選項
查看更多: http : //api.rubyonrails.org/v5.0/classes/ActiveSupport/Rescuable/ClassMethods.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.