How to get the rendered string without using render_to_strin

Hi,

I have a few sample letters that needs to be sent out. As part of the
specification the layout needs to be used and to be shown to legal and
then
mail those letters and log the full content in the database.

The strategy is to prepare full body before the email is actually sent
out.

In order to get the body of the email I was using,

body_of_email = render_to_string(:action =>
‘email_templates/letters_to_vendor’, :layout => false

It worked in some cases but now I am getting

Can only render or redirect once per action

Is there a way to get the output of the templates as a string after
substitution without using render functionality. I am new to Ruby.

Thanks

The render_to_string won’t cause that error. Furthermore, to render an
action you should use, “render_component_to_string”. You can also use
“render” directly and multiple times in your rhtml template to avoid
using _to_string
If that doesn’t fix it. some things to check:

Your filters: make sure any filter that redirects or renders something
returns false

The actions: any action you render must not allow a
“redirect_to”/“render” to occur more than ounce