1
我想访问我的current_user方法,该方法在SessionsHelper中定义。我如何包括或要求它为ApplicationCable连接类?Rails5 ActionCable包含来自SessionsHelper的current_user方法
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中我包括的SessionHelper在渠道/ application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
include SessionsHelper
identified_by :current_user
# (..)
end
end
,但不起作用。