How to pass variables to render_to_string?

前端 未结 5 637
余生分开走
余生分开走 2020-12-14 06:17

Trying to do the following

@message = render_to_string ( :sender => sender, :template => \"template\" )          

But when accessing

5条回答
  •  心在旅途
    2020-12-14 06:37

    I was trying to render a different format of partial in render_to_string. The thing which really worked for me was:

    render_to_string(:partial => 'partial_file.html', :locals => {:variable => variable}, :format => :html)

    where the name of the file was _partial_file.html.erb.

提交回复
热议问题