title: Rails 3 CSV and XLS export doesn't give file extension
body: <p>My users can generate a report of some data, and decide what format they want.</p>
  
  <p>They can choose HTML,CSV or XLS </p>
  
  <p>This is the form (Omitted the data stuff, this is just the format selector)   </p>
  
  <pre><code>&lt;%= form_tag "/report", :method =&gt; :get %&gt;
      Format &lt;select id='format' name='format'&gt;
                  &lt;option value='html' selected='selected'&gt;View in browser (HTML)&lt;/option&gt;
                  &lt;option value='csv'&gt;Export to CSV file&lt;/option&gt;
                  &lt;option value='xls'&gt;Export to exel (XLS)&lt;/option&gt;
              &lt;/select&gt;
  
  &lt;%= submit_tag "Make report", :class =&gt; 'submit' %&gt;
  </code></pre>
  
  <p>This form goes to this action</p>
  
  <pre><code>def report
      #...Again omitting data stuff
      respond_to do |format|
        format.html
        format.csv 
        format.xls 
      end
    end
  </code></pre>
  
  <p>I have corresponding view files.</p>
  
  <p>Like <code>report.xls.erb</code> </p>
  
  <p>In my log I get </p>
  
  <pre><code>Processing by ..Controller#report as XLS
  </code></pre>
  
  <p>But, <strong>the browser downloads the file without extension</strong>. </p>
  
  <p>If I change the form_tag line to this.</p>
  
  <pre><code>&lt;%= form_tag "/report.xls", :method =&gt; :get %&gt;
  </code></pre>
  
  <p>The file gets the .xls extension. </p>
  
  <p>I have set the xls mime_types</p>
  
  <p>How can I set the format in the form?</p>