开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜