title: Catch Unknown action in Rails 3 for custom 404
body: <p>I want to catch unknown action error in Rails 3, that shows "Unknown Action" error on development and the 404.html on production. I tried putting this <code>rescue_from</code> handler on my ApplicationController (and also on an actual controller, just in case) but I still see the ugly error.</p>
  
  <p>I have custom stuff on the 404, and it can't be plain .html file.</p>
  
  <p>My route:</p>
  
  <pre><code>match '/user/:id/:action', controller: 'users'
  </code></pre>
  
  <p>The URL I'm accessing: <code>/user/elado/xxx</code></p>
  
  <p>The <code>rescue_from</code> code:</p>
  
  <pre><code>rescue_from AbstractController::ActionNotFound, :with =&gt; :action_not_found
  
  def action_not_found
    render text: "action_not_found"
  end
  </code></pre>
  
  <p>The error in the browser:</p>
  
  <pre><code>Unknown action
  
  The action 'xxx' could not be found for UsersController
  </code></pre>
  
  <p>And in the console:</p>
  
  <pre><code>Started GET "/user/elado/xxx" for 127.0.0.1 at 2011-09-07 19:16:27 -0700
  
  AbstractController::ActionNotFound (The action 'xxx' could not be found for UsersController):
  </code></pre>
  
  <p>Tried also <code>rescue_from ActionController::UnknownAction</code>.</p>
  
  <p>Any suggestions?
  Thanks!</p>