我希望在我的Rails应用中只为一个特定操作设置不同的布局。我该怎么做?
答案 0 :(得分:26)
# controller that calls the page
def action
render :layout => 'other'
end
答案 1 :(得分:19)
class MyController < ApplicationController
layout "special", :only => :action
def action
#action code
end
end
答案 2 :(得分:9)
layout :resolve_layout
.
.
.
private
def resolve_layout
case action_name
when "new"
"alternate"
else
"application"
end
end