title: Rails - render :content_type has no effect
body: <p>I'm developing a Ruby/Rails app which scrapes another website and renders an RSS feed with the data.</p>
  
  <p>Because this app is built on Heroku, I am generating the RSS feed via a controller, rather than dumping it to the file-system and serving it as an asset.</p>
  
  <p>However when I set the <code>render :content_type</code> hash, there is no effect. The response's content type remains <code>text/plain</code>.</p>
  
  <p><code>news</code> action on <em><a href="https://github.com/freen/ubuwebrss/blob/master/app/controllers/feed_controller.rb" rel="nofollow">FeedController</a></em></p>
  
  <pre><code>def news
    do_scrape
    @posts = UbuEntry.all(:order =&gt; "created_at DESC", :limit =&gt; 400)
    render :layout =&gt; false, :content_type =&gt; Mime::RSS
  end
  </code></pre>
  
  <p>Full <a href="https://github.com/freen/ubuwebrss/blob/master/config/routes.rb" rel="nofollow">routes.rb</a></p>
  
  <pre><code>UbuWebRSS::Application.routes.draw do
    root :to =&gt; 'index#index'
    scope :format =&gt; true, :constraints =&gt; { :format =&gt; 'rss' } do
      get 'feed/news' =&gt; 'feed#news'
    end
  end
  </code></pre>
  
  <p>You can see the live outcome here:</p>
  
  <p><a href="http://www.ubuwebrss.com/feed/news.rss" rel="nofollow">http://www.ubuwebrss.com/feed/news.rss</a></p>
  
  <p>And the full source code:</p>
  
  <p><a href="https://github.com/freen/ubuwebrss/" rel="nofollow">https://github.com/freen/ubuwebrss/</a></p>
  
  <p>I've looked around on Google and StackOverflow but it's not clear what I'm doing wrong.</p>
  
  <p>Any tips? Thanks!</p>
  
  <p><strong>FYI:</strong></p>
  
  <p>The view script: <a href="https://github.com/freen/ubuwebrss/blob/master/app/views/feed/news.rss.builder" rel="nofollow">/app/views/feed/news.rss.builder</a>:</p>
  
  <pre><code>xml.instruct! :xml, :version =&gt; "1.0" 
  xml.rss :version =&gt; "2.0" do
    xml.channel do
      xml.title "UbuWeb"
      xml.description "UbuWeb is a completely independent resource dedicated to all strains of the avant-garde, ethnopoetics, and outsider arts."
      xml.link 'http://www.ubu.com'
  
      for post in @posts
        xml.item do
          xml.title post.title
  
          description = post.description.to_s
          unless description.empty?
            # Manually add description for custom HTML sanitizing
            description = @sanitizer_basic.clean(description)
            xml &lt;&lt; " " * 6
            xml &lt;&lt; "&lt;description&gt;&lt;![CDATA[" + description + "]]&gt;&lt;/description&gt;\n"
          end
  
          xml.pubDate post.created_at.to_s(:rfc822)
          xml.link post.href
          xml.guid post.href
        end
      end
    end
  end
  </code></pre>