新手问题 ruby-china 怎么拦截 404 错误的

yeyong14 · March 20, 2014 · Last by lgn21st replied at March 20, 2014 · 2041 hits

按照 ruby-china 的代码

def render_optional_error_file(status_code)
    status = status_code.to_s
    if ["404","403", "422", "500"].include?(status)
      render :template => "/errors/#{status}", :format => [:html], :handler => [:erb], :status => status, :layout => "application"
    else
      render :template => "/errors/unknown", :format => [:html], :handler => [:erb], :status => status, :layout => "application"
    end

好像拦不住的

这不是拦截代码,这是调用代码,是拦截之后才会调用的代码。

You need to Sign in before reply, if you don't have an account, please Sign up first.