rendez-vous avec le type mime spécifié qui ne se télécharge pas correctement dans les rails

J'utilise l'instruction suivante, mais il ne télécharge pas le file Excel plutôt qu'il télécharge le file text normal sur le browser.

render 'employees/checkin_report', :dates_arr => @dates_arr, :employees => @employees, :content_type => "application/vnd.ms-excel"

J'ai le file checkin_report.xls.erb , dans le dossier de vue des employés.

Si vous config/initializers/mime_types.rb dans votre projet. Vous verrez quelque chose comme ça.

 #Add new mime types for use in respond_to blocks: #Mime::Type.register "text/richtext", :rtf``` 

Vous pouvez save de nouveaux types MIME.

 | Short name | respond_to symbol | Aliases and explanations | |:---------------:|:-----------------:| ---------------------------:| | text/html | :html :html | application/xhtml+xml | | text/plain | :text, :txt | | | text/javascript | :js | application/javascript, | | | | application/x-javascript | | text/css | :css | Cascading style sheets | | text/calendar | :ics | iCalendar format for sharing| | | |meeting requests and tasks | | text/csv | :csv | Comma-separated values | | application/xml | :xml | text/xml, application/x-xml | | application/ | :rss | Really Simple Syndication | | rss+xml | |format for web feeds | | application/ | :atom | Atom Syndication Format for | | atom+xml | |web feeds | | application/ | :yaml | text/yaml--the human | | x-yaml | |readable | | | | Data serialization format | | application/ | :url_encoded_form | The default content type of | | x-www-form | |HTML forms | | urlencoded | | | | multipart/ | :multipart_form | Used for HTML forms that | | form-data | |contain files, non-ASCII | | | |data, and binary data | | application/json| :json | text/x-json, application/ | | | |jsonrequest-- | | | | Javascript object notaion | 

Je suis sûr qu'il existe plus de types MIME que vous pouvez implémenter. Ce sont les plus courants.