If No route match then redirect to root page

ruby-on-rails, ruby-on-rails-3

Solution

Make this statement the last in your `config/routes.rb` file:

match "*path" => redirect("/")

The `"*path"` will match anything and will redirect to the root path.

For more info, take a look at route globbing and redirection in the official Rails guides.

Problem

If I enter wrong route or if no routes match error comes then I want to redirect to root_path. How can I do this? Thank In Advance

Original source

Related problems