ruby on rails - Getting AuthLogic to work with ActionCable -


i'm working on new rails 5 (rc1) app. used authlogic user authentication, , works great always, until got 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 

i error: must activate authlogic::session::base.controller controller object before creating objects

i tried:

authlogic::session::base.controller = authlogic::controlleradapters::railsadapter.new(self) 

but not work because connection class not controller.

i @ authlogic code, can't figure out how bypass dependence on controller object. need load user's session. thoughts?

i figured out on own. feel sort of hacky, in applicationcontroller set secure cookie authlogic persistence_token, can read token , manually load user in actioncable.

class applicationcontroller < actioncontroller::base   before_action :set_verify_cookie    def set_verify_cookie     #action cable needs way outside of controller logic lookup user    return unless current_user     cookies.signed[:vvc] = current_user.persistence_token   end end  #app/channels/connection.rb module applicationcable   class connection < actioncable::connection::base     identified_by :current_user       def connect       self.current_user = find_verified_user       logger.add_tags 'actioncable', self.current_user.username unless self.current_user.nil?     end      protected      def find_verified_user_or_guest       user.find_by(:persistence_token => cookies.signed[:vvc])     end end 

one potential gotch, cookie needs cleared on logout or actioncable still find user on subsequent page loads.

#app/controllers/user_sessions_controller.rb class usersessionscontroller < applicationcontroller    def destroy     cookies.signed[:vvc] = nil     current_user_session.destroy     flash[:success] = "logout successful!"     redirect_to root_url   end end