When an exception is raised in development you get the full error along with the stack trace. In production, only a simple message is displayed. Learn why this is and how to customize the handling of exceptions.
# application.rb
def local_request?
false
end
def rescue_action_in_public(exception)
case exception
when ActiveRecord::RecordNotFound
render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
else
super
end
end
本文介绍Rails应用中不同环境下的异常处理方式。开发环境下显示详细的错误信息和堆栈跟踪,而生产环境中仅展示简单的错误消息。此外,还介绍了如何自定义异常处理逻辑。
168

被折叠的 条评论
为什么被折叠?



