简体   繁体   English

如何从ActionDispatch :: Cookie :: CookieOverflow中抢救?

[英]How to rescue_from ActionDispatch::Cookie::CookieOverflow?

First at all, I have read: 首先,我读到:

Cookie overflow in rails application? Cookie在Rails应用程序中溢出?

And this is not the problem that I'm facing. 这不是我要面对的问题。

I'm working with: 我正在与:

gem "rails", "~> 3.2.11"

and

ruby 1.9.3-p125

I'm trying to process a search, and when the search is tooooooo big I get this error: 我正在尝试处理搜索,当搜索太大时,出现此错误:

ActionDispatch::Cookies::CookieOverflow

I would like to rescue_form this error in the ApplicationController but it seems that is not working for me: 我想在ApplicationController中抢救这个错误,但似乎对我不起作用:

rescue_from ActionDispatch::Cookies::CookieOverflow :with => :render_404

where: 哪里:

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

any help is going to be well received. 任何帮助都会受到欢迎。

rescue_from ActionDispatch::Cookies::CookieOverflow :with => :render_404

you are missing comma (,) in arguments , according to docs 根据文档,您在参数中缺少逗号(,)

with correc syntax 使用correc语法

rescue_from ActionDispatch::Cookies::CookieOverflow, with: :render_404

rescue_from receives a series of exception classes or class names, and a trailing :with option with the name of a method rescue_from接收一系列异常类或类名,以及带有方法名的结尾:with选项

see more: http://api.rubyonrails.org/v5.0/classes/ActiveSupport/Rescuable/ClassMethods.html 查看更多: http : //api.rubyonrails.org/v5.0/classes/ActiveSupport/Rescuable/ClassMethods.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM