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

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.

On 8 Oct 2007, at 10:28, Fabien P. wrote:

(...)

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

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 :frowning:


http://penso.info/

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