开发者

How to call render on a view from inside an action?

开发者 https://www.devze.com 2023-02-14 10:29 出处:网络
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

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

精彩评论

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