我想访问在SessionsHelper中定义的current_user方法。我如何为ApplicationCable Connection 类包含或要求它?
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
if current_user
self.current_user = current_user
logger.add_tags current_user.name
end
end
end
end
给我
There was an exception - NoMethodError(undefined method `name' for nil:NilClass)
相当于 ApplicationController 我在 channels/application_cable/connection.rb 中包含了 SessionHelper
module ApplicationCable
class Connection < ActionCable::Connection::Base
include SessionsHelper
identified_by :current_user
# (..)
end
end
但不起作用。