Rails: display user friendly routing error message in rails
I am working in rails 2.3 on mac osx leopard. every time i type in a url that doesn't exist in rails app i get the following error:
Routing Error
No route matches "/whatever_i_typed" with {:method=>:get}
this is a development search, but I was wondering how I can make sure users see a friendlier 'oops! not found. "I was thinking about starting a rescue block ... but I didn't know where to put it, and I don't know the error code (like ActiveRecord :: RecordNotFound)
thank! Yuval
source to share
This error will never appear during production. Instead, users will see the public / 404.html page.
To try this on your localhost put passenger / mongrel in production mode. Override the method local_request?
on yours ApplicationController
like so:
class ApplicationController
def local_request?
false
end
end
If you want to experiment with dynamic behavior, you can check out the class method rescue_from
on ActionController.
source to share
I found the url below for Rails 3.0 users ..
http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
source to share