我正在尝试将网站分成两个部分。一种应该使用应用程序布局,另一种应该使用管理布局。在我的 application.rb 中,我创建了一个函数,如下所示:
def admin_layout
if current_user.is_able_to('siteadmin')
render :layout => 'admin'
else
render :layout => 'application'
end
end
在控制器中,它可能是我放置的一个或另一个
before_filter :admin_layout
这适用于某些页面(它只是文本),但对于其他页面,我得到经典错误:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
有人知道我缺少什么吗?我应该如何正确使用渲染和布局?