I’m trying to wrap my around a task and haven’t found anyone who has address this issue.
I’m created an awards nomination system.
- Anon user submits nomination
- Admin user generates a merged letter from template and edits letter
- Letter text is saved to database to later generate PDF
I read that you can render an ERB text to a variable. This is working great but then I’m stuck with the text because of the Double Render Error.
def generate_letter
@submission = Submission.find(params[:id])
@submission.letter_text = render (:text, :layout => false, :template => 'submissions/generate_letter') and return
@submission.save
redirect_to @submission
end
Is there a better way to generate this text for the database or a workaround to redirecting? I was trying to avoid keeping my merge template in the code and ERB seems a nice way to handle it.
You need to use
render_to_string. This lineshould be