【发布时间】:2010-11-10 19:33:36
【问题描述】:
我正在尝试将网站分成两个部分。一种应该使用应用程序布局,另一种应该使用管理布局。在我的 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
有人知道我缺少什么吗?应该如何正确使用渲染和布局?
【问题讨论】:
标签: ruby-on-rails layout render