Sebhastien
Sebhastien

Reputation: 97

How do I render a partial in a Text Area in a Rails form?

I am trying to create a email app that will use a template to create and send automated emails using an email template.

This is what I have tried to use...

<%= f.text_area :body, rows: "20", class: 'form-control', value: render :partial => 'emails/templates/consignment' %>

I just want the new email to be prepopulated with the html in my template.

Upvotes: 2

Views: 779

Answers (1)

Jakub
Jakub

Reputation: 743

In controller use render_to_string:

@email_template = render_to_string(:partial => 'emails/templates/consignment', :layout => false,:formats=>[:html])

In your view:

<%= f.text_area :body, rows: "20", class: 'form-control', value: @email_template %>

Upvotes: 2

Related Questions