2012-07-07 42 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視圖文件。