是否可以在Rails 3中的before_filter方法中重置默认布局?
我有以下作为我的contacts_controller.rb:
class ContactsController < ApplicationController
before_filter :admin_required, :only => [:index, :show]
def show
@contact = Contact.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @contact }
end
end
[...]
end
Run Code Online (Sandbox Code Playgroud)
以及我的application_controller.rb中的以下内容
class ApplicationController < ActionController::Base
layout 'usual_layout'
private
def admin_required
if !authorized? # please, ignore it. this is not important
redirect_to[...]
return false
else
layout 'admin' [???] # this is where I would like to define a new layout
return true …
Run Code Online (Sandbox Code Playgroud)