0
如何根据用户是否登录进行完全不同的布局?Rails:多个版面设计
如何根据用户是否登录进行完全不同的布局?Rails:多个版面设计
按照说明在
https://github.com/plataformatec/devise/wiki/How-To%3a-Create-custom-layouts
并进行检查是如果用户登录,这对于想方设法检查
user_signed_in?
,这是有一项帮手。
具体来说:
class ApplicationController < ActionController::Base
layout :layout_by_resource
protected
def layout_by_resource
if user_signed_in?
"special_layout_name_for_logged_in"
else
"application"
end
end
end
,并把在布局目录的special_layout_for_logged_in.html.erb
视图文件。