我试图将一个网站分成两部分。一个应该使用应用程序布局,另一个应该使用管理布局。在我的application.rb中我创建了一个功能如下:Ruby on Rails - 渲染布局
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
有没有人有我想念的想法?我应该如何正确使用渲染和布局?
如果logged_in?和current_user.is_able_to('siteadmin') current_user可能为零,如果没有登录! – 2009-07-15 06:57:36