Rails - Force XML template to be downloaded instead of rendered -


My question is very similar but the answer does not work for me. I have a custom XML file that I provide by the browser I want to download instead. I have tried the send_file method as the above question, but I also get an error hash can not be converted into a string .

Controller:

Answer_ | Format | Format.tmx end

Template: show.tmx.erb

  & lt ;? XML version = "1.0"? & Gt; & Lt; Tmx xmlns = "http://www.gala-global.org/oscarStandards/tmx/tmx14b.html" version = "1.4b" & gt; & Lt; / TMX & gt; See  

(I want this link to download a document instead of render in the browser):

  & lt;% = link_to " Download ", document_path (@document, format:" tmx ")%>  

You can use send_file, though it is already in the other endpoint of the setup You must mention the content supply or if you do not use XML in any other context, you can use the following:

  format.tmx {send_data render_to_string (: show), Filename: 'file.tmx', type: 'application / XML', nature: 'attachment'}  

hh,


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -