title: Rails 3 - Restricting formats for action in resource routes
body: <p>I have a resource defined in my routes.</p>
  
  <pre><code>resources :categories
  </code></pre>
  
  <p>And I have the following in my Category controller:</p>
  
  <pre><code>  def show
      @category = Category.find(params[:id])
  
      respond_to do |format|
        format.json { render :json =&gt; @category }
        format.xml  { render :xml =&gt; @category }
      end
    end
  </code></pre>
  
  <p>The controller action works fine for json and xml. However I do NOT want the controller to respond to html format requests. How can I only allow json and xml? This should only happen in the show action.</p>
  
  <p>What is the best way to achieve this?
  Also is there any good tips for DRYing up the respond_to block?</p>
  
  <p>Thanks for your help.</p>