title: How to return correct HTTP error codes from Ruby on Rails application
body: <p>I have RoR 3.0 web application which is acting as an OAuth API provider. Now, in API I'd like to return correct HTTP error codes to the API consumer. How do I do this?</p>
  
  <p>Here is example:</p>
  
  <pre><code>def destroy_oauth
      @item = Item.find(params[:id])
      if(!@item.nil? &amp;&amp; @item.user_id == current_user.id)
          @item.destroy
          respond_to do |format|
                  format.js
                  format.xml
          end
      else
          raise ActionController::RoutingError.new('Forbidden')
      end
  end
  </code></pre>
  
  <p>So, in case of error I'm trying to return Forbidden 403 code. Still, when running this I'm getting always 404 Not Found returned. How do I return the correct code?</p>
  
  <p>Or is this somehow webserver configurable thing?</p>