【发布时间】:2010-02-16 11:01:39
【问题描述】:
我尝试在动作中编写渲染,但布局行为不同,为什么?
def show
# assuming we have a partial in app/views/shared/_panel_show.html.erb
#render "shared/_panel_show" # have layout
#render "/shared/_panel_show" # without layout
#render "shared/panel_show" # Template is missing
#render :partial => "shared/panel_show" # without layout
render :partial => "/shared/_panel_show",:layout => "application" # have layout
end
我想渲染部分并遵循控制器布局。
【问题讨论】:
-
有什么不同?你不应该这样做吗:render :partial => "/shared/panel_show",:layout => "application" ?
-
是的,我可以。但我想使用控制器定义的布局。当我更改全局布局时,我不想修改很多地方。
标签: ruby-on-rails layout render partial actioncontroller