I have some complex message to show inside of a flash message so instead of having a long string in the controller, I extracted it to a partial. I do this:
flash[:success] = render(:partial => "complicated_message")
…
respond_to do |format|
format.html
format.js
end
and then a normal view should be rendered which display the flash. This is a double render error, of course, since I have “wasted” a render on the partial.
What is a better way to do this?
The answer, as suggested by @jdoe is to use the render_to_string method instead.