我正在将我的应用程序切换到 Rails 3,目前我发现 log_error 方法存在一些问题。在文档(http://apidock.com/rails/ActionController/Rescue/log_error)中,他们说最后一个版本在 2.3.8 中,所以在这种情况下,它不起作用是正常的。
但是当我检查替代方案时,他们提出了http://apidock.com/rails/ActionDispatch/ShowExceptions/log_error这在 rails 3 中受支持。但他仍然告诉我“未定义的方法 log_error”。
我在我的应用程序控制器中使用它如下:
def render_not_found(exception = nil)
log_error(exception) if exception
#notify_hoptoad(exception)
render :template => "/help/404.html.erb", :status => 404
end
def render_error(exception)
log_error(exception)
notify_hoptoad(exception)
render :template => "/help/500.html.erb", :status => 500
end
那么如何在 Rails 3 中使用方法 log_error 呢?或者这种方法有替代方法吗?