Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9535 (closed defect: invalid)

Opened 3 years ago

Last modified 1 year ago

Repond_to fails with IE7 and custom registed mime types

Reported by: jerome Assigned to: core
Priority: high Milestone: 1.x
Component: ActiveSupport Version: 1.2.3
Severity: major Keywords: ie7
Cc: evan

Description

Internet Explorer 7, which can handle any type (*/*), does request the "xls" mime type if registered instead of html, even if html is the first listed type to serve.

environment.rb:

Mime::Type.register "application/vnd.ms-excel", :xls
Mime::Type.register "text/plain", :txt

controller:

respond_to do |format|
  format.html
  format.xls # default type served to IE7 !
  format.txt
end

Change History

09/11/07 22:26:10 changed by evan

  • cc set to evan.

09/12/07 09:23:50 changed by jerome

Some details:

HTTP_USER_AGENT : Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30) HTTP_ACCEPT : image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, */*

Then it's impossible to force and serve html by default !?

09/12/07 09:41:07 changed by evan

  • status changed from new to closed.
  • resolution set to invalid.

Looks that way. You'll have to make IE request the file extension instead of relying only on the mimetype.

02/25/09 17:22:35 changed by phs

I know this trac is deprecated in favor of lighthouse, but googling brought me here first anyway, so I'll drop my solution here.

In rails 2.2.2, I was able to force html by default to IE by explicitly setting paramsformat?:

# application.rb

before_filter :hijack_ie_default_format
def hijack_ie_default_format
  if request.user_agent =~ /MSIE/ and params['format'].nil?
    params['format'] = 'html'
  end
end