IE: Unknown file type (request.format rails issue)

Bug description: On IE (and only on IE),  some hml pages are treated as binary files: a ‘unknown file type’ dialog box. The actions where this issue appears render their content after the request type:

…..
respond_to do |format|
format.js{
……..
}

format.html{
………
}

end

The issue is related on how the browsers send the HTTP_ACCEPT header:

FF: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
IE:  “image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*”

As you can see, the ‘text/html’ is not explicitly included (it is however implicitly included in ‘*/*’ part, which is the last)

The bottom line is that rails env matches wrongly the response_type.

Solution: you must put format.html part BEFORE format.js

respond_to do |format|
format.html{
…………
}
format.js{
…………
}
end

Advertisements

One Response

  1. In order to get rid of this problem and find a suitable way to discover the appropriate program for an unknown file type, you can check out the OpenWith.org Desktop Tool.

    http://mwolk.com/blog/how-to-open-unknown-file-types/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: