How can I render an HTML view into a string(saved in the database) to be able to render it back from it in rails?
def show_offer
respond_to do |format|
format.html { render 'offer_template_one', :layout => 'templates'}
format.pdf do
render :pdf => 'oferta',
:template => 'templates/show_offer.pdf.erb',
:layout => "layouts/templates.html.erb",
:save_to_file => Rails.root.join('public', "Oferta.pdf")
end
end
end
This is the method through which I'm rendering my view
Thanks!
Ok, I got it to work with render_to_string method:
@offer_string = render_to_string(:template => 'templates/offer_template_one.html.erb', :layout => false)
# Renders the clear text "hello world" with status code 200
render :text => "hello world!"
# Renders the clear text "Explosion!" with status code 500
render :text => "Explosion!", :status => 500
# Renders the clear text "Hi there!" within the current active layout (if one exists)
render :text => "Hi there!", :layout => true
# Renders the clear text "Hi there!" within the layout
# placed in "app/views/layouts/special.r(html|xml)"
render :text => "Hi there!", :layout => "special"
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