Can't register .xls as custom MIME type in Rails4

I updated config / initializers / mime_types.rb and restarted the server.

Mime::Type.register "application/vnd.sealed-xls", :xls

      

My controller looks like this:

respond_to do |format|
  format.xls {  send_file(file_name, filename:  "dagsrapport.xls")  }
  format.html
end

      

This is the error I get when I do a GET on /sheet.xls

To respond to a custom format, register it as a MIME type first: 
http://guides.rubyonrails.org/action_controller_overview.html#restful-downloads. If you meant to 
respond to a variant like :tablet or :phone, not a custom format, be sure to nest your variant 
response within a format response: format.html { |html| html.tablet { ... } }

      

Any tips on what I'm missing? I can't see what I am doing wrong according to the doc: http://guides.rubyonrails.org/action_controller_overview.html#restful-downloads

+3


source to share


1 answer


All I did to register the xls as a Mime type was just added to config / initializers / mime_types.rb Mime::Type.register "application/xls", :xls

and restarted the server. Hope this helps.



+6


source







All Articles