Today I noticed that List Kung Fu displays the mobile version of the list page when I browse there with regular desktop Internet Explorer. Surfing to the same page with Firefox or Opera on the same machine worked fine and just returned the regular HTML page.
So what’s up?
Simple… Internet Explorer sends a really funny accepts header, none of the formats actually is text/html. Thus HTML is covered with an implicit */*. That’s not awesome (in good IE manner), but not really a problem. A problem it just becomes with something like this in your controller action:
respond_to do |format| format.mobile format.html end
Since Internet Explorer doesn’t send an explicit accept for text/html, Rails would just default to the first format, in above case format.mobile and then correctly return the mobile version of the view. The fix is easy. Just move format.html to the first position:
respond_to do |format| format.html format.mobile end
Now */* would default to format.html.
I'm a Software Developer, currently working at
Thanks for posting this. I’ve solved my related issue by setting a before_filter like this:
def set_default_response_format
request.format = :html if params[:format].nil?
end
IE8 requests are now processed correctly.