Jus*_*tin 3 ruby ruby-on-rails http-status-code-404 ruby-on-rails-4
似乎无法让它工作......它仍然显示默认的错误页面......
使用RAILS 4
这是我的代码..
ErrorsController
def not_found
  render :status => 404
end
def unacceptable
  render :status => 422
end
def internal_error
  render :status => 500
end
application.rb中
config.exceptions_app = self.routes
的routes.rb
match "/404", :to => "errors#not_found", via: 'get'
match "/422", :to => "errors#unacceptable", via: 'get'
match "/500", :to => "errors#internal_error", via: 'get'
我对所有这些文件都有适当的视图
为什么它仍然呈现默认的rails错误消息?
你可以去config/environments/development.rb并改变以下行,
config.consider_all_requests_local = true
至
config.consider_all_requests_local = false
虽然我自己没有尝试过,但它应该在开发过程中启用错误消息.默认允许您查看调试模式.