Rails: Turn off error display

雨燕双飞 提交于 2019-12-03 20:25:24

问题


When I access a post that doesn't exist in my Rails project via the URL /posts/13, the browser shows a verbose error:

ActiveRecord::RecordNotFound in PostsController#show

Couldn't find Post with ID=13
Rails.root: ...
...
Request

Parameters:

{"id"=>"13"}
...

Is there a way to turn this detailed error display off?


回答1:


Try this:

  • run a server in production $ rails s -e production

  • remove ActionDispatch::DebugExceptions middleware

    config.middleware.delete(ActionDispatch::DebugExceptions)

  • set config.consider_all_requests_local = false in your environment config



来源:https://stackoverflow.com/questions/12849597/rails-turn-off-error-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!