Rendering file with MIME Type in rails

后端 未结 5 527
误落风尘
误落风尘 2020-12-28 17:52

Here\'s the code:

render :file => @somedir + \"/blah.xml\"

...but the resulting MIME type is text/html when I check in FireBug. How do I

5条回答
  •  情歌与酒
    2020-12-28 18:17

    Per http://api.rubyonrails.org/classes/Mime/Type.html, you could specify it like so:

    render file: @somedir + "/blah.xml", mime_type: Mime::Type.lookup("text/xml")  
    

提交回复
热议问题