Reputation: 1807
I'm switching my application to Rails 3 and for the moment I discover some problems with the log_error method. In the doc ( http://apidock.com/rails/ActionController/Rescue/log_error ) they say that the last version is in 2.3.8 so in this case it is normal that it is not working.
But when I check then the alternatives, they propose http://apidock.com/rails/ActionDispatch/ShowExceptions/log_error which is supported in rails 3. But still he's telling me "undefined method log_error".
I use it in my application controller as following:
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
How can I use the method log_error in Rails 3 then? Or is there an alternative for this method?
Upvotes: 3
Views: 1180
Reputation: 4113
Method you want to use is private
so you cannot call it explicitly.
I think you should use something like this to show exception:
message = "\n#{exception.class} (#{exception.message}):\n"
Rails.logger.warn(messafe)
It is just a guess, so you free to customize it for your needs.
Upvotes: 1