新手问题 Action Cable 一直报一个错 undefined method `identified_by' for ApplicationCable::Channel:Class

ad583255925 · 2017年04月20日 · 最后由 ad583255925 回复于 2017年04月21日 · 1145 次阅读

有人碰到过吗

module ApplicationCable
  class Channel < ActionCable::Channel::Base
    identified_by :current_user

    def connect
      self.current_user = find_verified_user
    end

    private
    def find_verified_user
      if verified_user = User.find_by(id: cookies.signed[:user_id])
        verified_user
      else
        reject_unauthorized_connection
      end
    end

  end
end

你是想照着 rails guide 来做的吗

class Connection < ActionCable::Connection::Base
    identified_by :current_user

贴错地方了😅 顺便问下 cable 这个东西进程和内存占用怎么样,怎么能方便的开关

需要 登录 后方可回复, 如果你还没有账号请 注册新账号