Neeraj Kumar
2007-Aug-16 17:41 UTC
How to get the rendered string without using render_to_string
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Keynan Pratt
2007-Aug-16 23:26 UTC
Re: How to get the rendered string without using render_to_s
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---