How can I render a partial to a String in Ruby on Rails 4.2, since render_to_string
is deprecated?
Something like:
rendered_string = render_to_string partial: 'forgotten_orders/soonest_manufacturing_date', locals: { forgotten_order: forgotten_order, soonest_manufacturing_date: soonest_manufacturing_date }
You can just use render
. My demo:
In my view:
<% foo = render 'foo_thing', bar:"formal bar" %>
<%= foo %>
In _foo_thing.html.erb
:
<%= "This bar is a #{bar}" %>
And on my screen:
This bar is a formal bar
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