2012-07-07 66 views

回答

1

按照说明在
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视图文件。