Rails5 ActionCable include current_user method from SessionsHelper
<p>I want to get access to my <strong>current_user</strong> method which is defined in the <strong>SessionsHelper</strong>. How can I <strong>include</strong> or require it for the <strong>ApplicationCable</strong> Connection class?</p>

<pre><code>module ApplicationCable
  class Connection &lt; 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
</code></pre>

<p>gives me</p>

<pre><code>There was an exception - NoMethodError(undefined method `name' for nil:NilClass)
</code></pre>

<p>Equivalent to the ApplicationController I <strong>included</strong> the SessionHelper in channels/application_cable/connection.rb</p>

<pre><code>module ApplicationCable
  class Connection &lt; ActionCable::Connection::Base
    include SessionsHelper
    identified_by :current_user
    # (..)
  end
end
</code></pre>

<p>but doesn't work.</p>