I've got the following error:
ActionController::RoutingError (No route matches [GET] "/images/favicon.ico")
I want to show error404 page for links that are not existing.
How can I achieve that?
I've got the following error:
ActionController::RoutingError (No route matches [GET] "/images/favicon.ico")
I want to show error404 page for links that are not existing.
How can I achieve that?
Copying favicon image in
app/assets/images
worked for me.@Andrey Deineko, your solution seems to work only for the
RoutingError
s raised manually inside a conrtoller. If I try it with the urlmy_app/not_existing_path
, I still get the standard error message.I guess this is because the application doesn't even reach the controllers, since Rails raises the error before.
The trick that solved the problem for me was to add the following line at the end of the routes:
to catch all not predefined requests.
Then in the ErrorsController you can use
respond_to
to serve html, json... requests:In
application_controller.rb
add the following:I usually also rescue following exceptions, but that's up to you:
Create the errors controller:
Then in
routes.rb
And the last thing is to create
not_found.html.haml
(or whatever template engine you use) under/views/errors/
: