我試圖在動作中編寫渲染,但佈局行爲不同,爲什麼?如何在控制器中呈現工程?爲什麼它不使用佈局?
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」? – marcgg
是的,我可以。但我想使用控制器定義的佈局。當我改變全球佈局時,我不想修改很多地方。 – allenwei