Why are IE6 and Firefox rendering different formats from the same URL?

I have a controller action in my Rails 2.0.2 app that looks like this:

def matrix
@shows = Show.find(:all)
@players = Player.find(:all)
respond_to do |format|
format.xls do

In Firefox, this works exactly as expected - when I go to /signups/
matrix, I get the HTML format rendered. If I go to /signups/
matrix.xls, I get the Excel version.

However, when I do the same thing on IE6/XP, I get the Excel format
rendered for both. /signups/matrix tries to download the Excel file.

The log doesn’t show anything odd that I can tell:

Processing SignupsController#matrix (for at 2008-05-14
20:03:57) [GET]
Session ID: 39a88d1fff075058276e65d67136f7dd
Parameters: {“action”=>“matrix”, “controller”=>“signups”}


Completed in 0.23381 (4 reqs/sec) | Rendering: 0.03932 (16%) | DB:
0.09844 (42%) | 200 OK []

I’m stumped - does anyone know why this would be happening?


The key to this behavior is the Accept header of the HTTP request. You
check it in Rails with request.headers[‘HTTP_ACCEPT’] (see

IE6 prefers MS Office content (Excel, Powerpoint, Word) over HTML:

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/msword, application/vnd.ms-powerpoint, /

(I got this from
as I don’t have IE6 installed.)

So (X)HTML mimetypes don’t even appear explicitly, they’re caught by the
wildcard / and have the lowest priority.

Very strange, but this is how Microsoft wanted it to be. They fixed this
the meantime. The Internet Explorer 8 beta header says simply:
Accept: /

To be sure to get the HTML rendering, say /signups/matrix.html . I guess
you could also tinker with your HTTP server settings to give the HTML
mimetypes higher priority.

Thanks for the tip - I went in and changed application/vnd.ms-excel to
application/octet-stream in the initializer/mime_types.rb file, and it
seems to be performing expected behavior now.

Thanks again!


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs