0

I think subject says it all. Would something like this work?

class ApplicationController < ActionController::Base
  rescue_from Exception, :with => :bad_call

  def bad_call
    # how would I log the specific sql for ActiveRecord::RecordNotFound
  end
end

Sorry for vague question but should be clear from the question and would be a tremendous help. How would I log this information esp in development?

ths in advance

tereško
  • 58,060
  • 25
  • 98
  • 150
timpone
  • 19,235
  • 36
  • 121
  • 211
  • I think this is tricky and would require monkeypatching, as the SQL query isn't included as part of the exception. – smw Feb 12 '13 at 21:59

1 Answers1

0

If I did understand you right then that should be it.

rescue_from ActiveRecord::RecordNotFound do |exception|
  Rails.logger.info exception
end

I'd also suggest reading the topic about why it is bad to rescue from Exception.

UPD: Oh, I guess I'm wrong. That won't give you the SQL query if this is what you need.

Community
  • 1
  • 1
JazzJackrabbit
  • 515
  • 2
  • 10