Global error handling in rails

Hey people,

I’m having a problem implementing global error handling in Rails.

I’m using “Agile Web D. with Rails”, and on page 464 it has
some code for
implementing email notification of such errors via the
rescue_action_in_public
method globally in application.rb. I’ve implemented it, but I’m seeing
this in
my logs

NameError (uninitialized constant
ActionWebService::Dispatcher::ActionController
::UnknownAction):

/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dep
endencies.rb:100:in `const_missing’

/app/controllers/application.rb:14:in `rescue_action_in_public'

/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/re
scue.rb:33:in `rescue_action’

And I’m getting “Application error (Rails)” in the browser.

Any suggestions?

Thanks,
Mike

msoulier wrote:

NameError (uninitialized constant
ActionWebService::Dispatcher::ActionController
::UnknownAction):

Apparently the problem is documented in the errata on the website for
the
book. This fixes the problem.

[[email protected] papproach]$ hg diff -r 27 -r 28

diff -r 282a076a19ac -r f1f71757bb90 app/controllers/application.rb

— a/app/controllers/application.rb Sun Sep 24 16:53:02 2006 -0400

+++ b/app/controllers/application.rb Thu Sep 28 20:27:56 2006 -0400

@@ -11,7 +11,7 @@ class ApplicationController < ActionCont

 def rescue_action_in_public(exception)

     case exception
  •    when ActiveRecord::RecordNotFound,
    

ActionController::UnknownAction

  •    when ActiveRecord::RecordNotFound,
    

::ActionController::UnknownAction
render(:file => “#{RAILS_ROOT}/public/404.html”,

                :status  => "404 Not Found")

     else

I don’t understand the fix, but it does work.

I don’t suppose anyone can explain it.

Mike

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs