I'm trying to create a view with a download link to download the html source?
@Peter 's solution worked for me. Here is a code sample:
View:<%= link_to 'download this page', object_path(@object, :download => true) %>
Controller:
def show # ... if params[:download] send_data(render_to_string, :filename => "object.html", :type => "text/html") else # render normally end end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With