Wednesday, December 23, 2009

[Rails] rescue_from ActionController::RoutingError

Relative newb here.

Is there a relatively simple way to gracefully trap routing errors?

I seem to be in the same boat with a lot of other people ...

In application.rb I have

#----------------

# Filters added to this controller apply to all controllers in the
application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time

# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => '34e000fc7cc2daeae150a89535f7f87d'

# Be sure to include AuthenticationSystem in Application Controller
instead
include AuthenticatedSystem

#Shnelvar
debugger # This one gets hit
rescue_from ActionController::RoutingError, :with => :route_not_found
# rescue_from ActionController::RoutingError, :with => :render_404

protected

def route_not_found
debugger #this one does not
render :text => 'What are you looking for ?', :status => :not_found
end
#Shnelvar end

end

#----------------


Tracing through the code, the first breakpoint gets hit. The second
does not.

Further tracing shows that the line
rescue_handlers << [key, options[:with]]
in
\ruby\lib\ruby\gems\1.8\gems\actionpack-2.0.2\lib\action_controller\rescue.rb
seems to be working.


I have looked in these archives. I have googeled things related to
rescue_from ActionController::RoutingError
and smoe people get this to work. Some people need to put stuff in
lower level controllers ... but I have not gotten that to work, either.
--
Posted via http://www.ruby-forum.com/.

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate