Ruby on rails 两个“;“全球”/应用程序布局
我是Rails新手,我想知道是否有可能有两种不同的应用程序布局?我希望我的网站的公共界面看起来不同于管理员看到的。因此,所有公共操作将在一个应用程序布局中呈现,而所有管理操作将在另一个应用程序布局中呈现 您可以决定在应用程序\u控制器中的Ruby on rails 两个“;“全球”/应用程序布局,ruby-on-rails,ruby,Ruby On Rails,Ruby,我是Rails新手,我想知道是否有可能有两种不同的应用程序布局?我希望我的网站的公共界面看起来不同于管理员看到的。因此,所有公共操作将在一个应用程序布局中呈现,而所有管理操作将在另一个应用程序布局中呈现 您可以决定在应用程序\u控制器中的前过滤器中使用哪个布局 class ApplicationController < ActionController::Base # other implementation layout :determine_layout def de
前过滤器
中使用哪个布局
class ApplicationController < ActionController::Base
# other implementation
layout :determine_layout
def determine_layout
current_user.admin? ? "admin" : "application"
end
end
class ApplicationController
您可以确定在应用程序\u控制器中的过滤器之前使用哪个布局
class ApplicationController < ActionController::Base
# other implementation
layout :determine_layout
def determine_layout
current_user.admin? ? "admin" : "application"
end
end
class ApplicationController
class ApplicationController
class ApplicationController