title: Redirect and raise flash message when catch-all in routes
body: <p>I am able to <a href="http://guides.rubyonrails.org/routing.html#redirection" rel="nofollow noreferrer">redirect</a> all (invalid) urls using <a href="https://stackoverflow.com/questions/4132039/rails-redirect-all-unknown-routes-to-root-url">this line at the end of the routes file</a>:</p>
  
  <pre><code>match '*a' =&gt; redirect('/') 
  </code></pre>
  
  <p>I'd like to do the redirect and pass on an alert message in <code>routes.rb</code>.<br>
  Something like (the syntax is wrong here):</p>
  
  <pre><code>match '*a' =&gt; redirect('/'), :alert =&gt; "aaargh, you don't want to go to #{params[:a]}"
  </code></pre>
  
  <p>Is it possible to do this?</p>
  
  <p><em>If I were doing this in a view/controller, I could use <code>redirect_to</code> and pass on a flash message on the redirected page (see examples in <a href="http://api.rubyonrails.org/classes/ActionController/Redirecting.html" rel="nofollow noreferrer">redirecting in the docs</a>). Creating a new controller method and redirecting there would work, but it seems inelegant... is it the recommended way?</em></p>