Reputation: 3537
I want to make a simple page with a back button for the odd case that a user enters a url to a page there is not route for.
For instance, the route for foo
is:
resources :foos, :except => [:index]
The user enters:
mysite.com/foos
I want to display a page that says "This page doesn't exist" and a back button.
Where do I put the html.erb file and how to I account for that in routes.rb?
Thanks
Upvotes: 2
Views: 83
Reputation: 6088
At the end of your routes.rb write:
match '*path', :controller => 'some_controller', :action => 'some_action'
or
match '*path' => 'some_controller#some_action'
Source:
Upvotes: 2
Reputation: 20313
As per my knowledge you have two ways to do this:
Example: How to properly render custom 404 and 500 pages?
2.Custom Error Page - Ruby on Rails
Upvotes: 1
Reputation: 1545
When a client's request can not be found in the server, a 404 redirect is made. To costumize the 404 page, simply change it in public/404.html
Upvotes: 0
Reputation: 1025
In the production mode, the 404.html
in the /public
folder of your Rails Application will be renderd for a Routing Error instead of displaying the error message.
Upvotes: 1