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

ad583255925 · April 20, 2017 · Last by ad583255925 replied at April 21, 2017 · 1146 hits

有人碰到过吗

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 这个东西进程和内存占用怎么样,怎么能方便的开关

You need to Sign in before reply, if you don't have an account, please Sign up first.