我正在開發一個新的Rails 5(RC1)應用程序。我使用AuthLogic進行用戶身份驗證,並且它一直很好,直到我有了ActionCable。使AuthLogic與ActionCable一起工作
#app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = UserSession.find
end
end
end
我得到的錯誤:你必須用一個控制器對象激活Authlogic ::會議:: Base.controller創建對象
我嘗試過:
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
但是,這並不因爲Connection類不是控制器。
我看着AuthLogic代碼,但我無法弄清楚如何繞過它對控制器對象的依賴。我只需要加載用戶的會話。有什麼想法嗎?
很不錯的解決方案!很好的答案。 請只編輯這一行:'self.current_user = find_verified_user' For:'self.current_user = find_verified_user_or_guest' – ZombieBsAs