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

yeyong14 · 2014年03月20日 · 最后由 lgn21st 回复于 2014年03月20日 · 2041 次阅读

按照 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

好像拦不住的

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

需要 登录 后方可回复, 如果你还没有账号请 注册新账号