0
在我的應用我想使用時,用戶登錄不同的佈局,而不是Rails的:不同的佈局
application_controller:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
layout :determine_layout
private
def determine_layout
user_signed_in? ? 'application' : 'landing'
end
end
但這種代碼不工作:佈局不改變。可以設想造成這種情況嗎?或者我犯了一些錯誤?
謝謝!
代碼看起來沒問題,這是您一直有的佈局? – apneadiving
當用戶登錄它的'應用程序',並且當用戶沒有登錄佈局時,它是'登陸' –
好,所以你的方法工作... – apneadiving