Rails 4 - export entire html page for loading

I want to provide an export function on my website so that the user can download the html content that I have installed, including the css that comes with it (this is the same CSS that I use throughout the website).

How can I give the user a button that loads an html file that is just a view from one of my controller actions?

Thank.

+3


source to share


1 answer


The option that worked for me was this. In the action you're ready to do in plain text, just add this line:

render  content_type: 'text/plain'

      

This will release the text version of your html page, but it will not generate the whole css inline. If that is the goal, then you have to define a separate layout that will put the original version of your css on a string.

EDIT:



In this case, you can probably use the HTML5 feature:

<a href="path/to/file" download>Click here to download</a>

      

Source: Force browser to save file after clicking link

0


source







All Articles