# Respond\_to weirdness

**URL:** <https://www.ruby-forum.com/t/respond-to-weirdness/143931>\
**Category:** Rails\
**Created:** [July 23, 2008, 11:37pm UTC](https://www.ruby-forum.com/t/respond-to-weirdness/143931 "2008-07-23T23:37:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_McIntyre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tim\_McIntyre](https://www.ruby-forum.com/u/Tim_McIntyre)\
**Post date:** [July 23, 2008, 11:37pm UTC](https://www.ruby-forum.com/t/respond-to-weirdness/143931/1 "2008-07-23T23:37:39Z")

</div>

Hey all,

Here is the suspect code, description follows.

environment:  
Mime::Type.register “text/csv”, :csv

controller:  
def sales\_report  
…  
…  
respond\_to do |f|  
f.csv { send\_data(csvify(@sales), :filename =\> “sales-report–  
#{@period}.csv”) }  
f.html { render(:layout =\> “sales\_report”) }  
end  
end

view:

form tag to generate the report -  
form\_for(:film\_id, :html =\> {:method =\> “GET”}, :url =\>  
formatted\_member\_sales\_report\_path(:user\_id =\> @user.id, :id =\>  
@account.id, :format =\> “html”))

link to download generated report as CSV file:  
link\_to(“Download CSV Report”,  
formatted\_member\_sales\_report\_path(:user\_id =\> @user.id, :id =\>  
@account.id, :format =\> “csv”))

First of all this is in rails 1.2.3 (yes upgrade is in the works:-).  
The weirdness is that everything works perfectly on my local dev box  
and our test server running in either development or production mode.  
But on our live production box it will only return the HTML page and  
never the CSV download.

The only significant differences between the boxes are that we’re  
running mod\_rails on both my local dev box and the test server but  
mongrels on the live/production box. Could that be it? Seems to me  
there must be something else going on.

Any thoughts greatly appreciated,  
Tim

---

<div class="post-metadata">

**Author:** ![Tim\_McIntyre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tim\_McIntyre](https://www.ruby-forum.com/u/Tim_McIntyre)\
**Post date:** [July 24, 2008, 7:46am UTC](https://www.ruby-forum.com/t/respond-to-weirdness/143931/2 "2008-07-24T07:46:10Z")

</div>

> environment:  
> Mime::Type.register “text/csv”, :csv

I’ve had some troubles with this before.  
Some thoughts: double check the register stuffs,  
try to recreate the production environment on your dev box.  
step through with ruby-debug [through the tedious rails stuff] and see  
what’s going on.  
The only thing I’ve had similar is I registered ‘over’ an existing type  
before and that didn’t work because FF3 had its “accept’s” in a  
different order than other browsers. Something like that.  
-R
