当我通过url/posts/13访问rails项目中不存在的帖子时,浏览器显示一个详细错误:

ActiveRecord::RecordNotFound in PostsController#show

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

Parameters:

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

是否有方法关闭此详细错误显示?

最佳答案

试试这个:
在生产环境中运行服务器$ rails s -e production
删除ActionDispatch::DebugExceptions中间件
config.middleware.delete(ActionDispatch::DebugExceptions)
在环境配置中设置config.consider_all_requests_local = false

10-01 07:13
查看更多