我正在尝试将一个网站分成两个部分。一个应该使用应用程序布局,另一个应该使用管理布局。在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
有人知道我错过了什么吗?如何正确使用render和layout?
https://stackoverflow.com/questions/1128080
复制相似问题