I am able to redirect all (invalid) urls using this line at the end of the routes file:
match '*a' => redirect('/')
I'd like to do the redirect and pass on an alert message in routes.rb
.
Something like (the syntax is wrong here):
match '*a' => redirect('/'), :alert => "aaargh, you don't want to go to #{params[:a]}"
Is it possible to do this?
If I were doing this in a view/controller, I could use redirect_to
and pass on a flash message on the redirected page (see examples in redirecting in the docs). Creating a new controller method and redirecting there would work, but it seems inelegant... is it the recommended way?