开发者

render a view within a view

开发者 https://www.devze.com 2023-01-09 22:00 出处:网络
How do I render a view within another view... 开发者_如何学Goin rails... is it possible?#hotdog_controller

How do I render a view within another view... 开发者_如何学Goin rails... is it possible?


#hotdog_controller
def show
  # by default renders template hotdog/show.html.erb
end

#hotdog/show.html.erb
<%= render :template => 'ketchup' -%>


Use view partials

See section 3.4 http://guides.rubyonrails.org/layouts_and_rendering.html


A complete view inside another a view? Normally the way you would handle something like this in rails would be with partials.

Create a set of shared partials, and then just render them in each of the views.


I do the same thing a few times, but I load the sub views in through AJAX. And that AJAX is instantiated within the partial.

0

精彩评论

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

关注公众号