Fabien Penso
2007-Oct-08 09:28 UTC
Rails 2.0 : handling routing error (Was: fallback to a default controller action)
> Rails 2.0 has a much nicer way of dealing with this, since you can do > > class PostsController < ApplicationController > rescue_from FooError, :with => :foo_handler > > protected > def foo_handler > end > endI am trying to use this to display the 404 HTML file in case of routing error : rescue_from ActionController::RoutingError, :with => :show_404 But it never gets called, and I still get a : No route matches "/foo" with {:method=>:get} vendor/rails/actionpack/lib/action_controller/routing.rb:1411:in `recognize_path'' (...) Any idea ? I am in production environment. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-08 09:42 UTC
Re: Rails 2.0 : handling routing error (Was: fallback to a default controller action)
On 8 Oct 2007, at 10:28, Fabien Penso wrote:> >> Rails 2.0 has a much nicer way of dealing with this, since you can do >> >> class PostsController < ApplicationController >> rescue_from FooError, :with => :foo_handler >> >> protected >> def foo_handler >> end >> end > > I am trying to use this to display the 404 HTML file in case of > routing error : > > rescue_from ActionController::RoutingError, :with => :show_404 > > But it never gets called, and I still get a : > > No route matches "/foo" with {:method=>:get} > vendor/rails/actionpack/lib/action_controller/routing.rb:1411:in > `recognize_path'' > (...) > > Any idea ? I am in production environment. >Where have you put your rescue_from ? I haven''t used this much, but I''d guess that you''d have to have this in application.rb for this to even stand a chance of working for a routing error. Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Fabien Penso
2007-Oct-09 00:02 UTC
Re: Rails 2.0 : handling routing error (Was: fallback to a default controller action)
> Where have you put your rescue_from ? I haven''t used this much, but > I''d guess that you''d have to have this in application.rb for this to > even stand a chance of working for a routing error.I did put it in application.rb, but it doesn''t work :( -- http://penso.info/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---