How to call render on a view from inside an action?
I want to get the rendered response from the action BEFORE it returns, so something like:
def test
my_html = # R开发者_如何学运维ENDER VIEW HERE AND ASSIGN TO VARIABLE
render :text => my_html
end
How can I do this?
You could use render_to_string
def test
my_html = render_to_string(:action => :show)
render :text => my_html
end
render_to_string accepts all options that render does.
精彩评论