title: Unique channels for each 2 users on ActiveCable - Rails
body: <p>I've been studying ActionCable and spent many hours trying to figure out how it works, and did lot's of researches, but I'm still trying to get satisfactory solutions for me. I have a better understanding now. I managed to subscribe users for a chat and update in real-time, but I don't know what should I do to <strong>create specific channels for each 2 users</strong> (just like a messenger). Should I specify these channels on <code>stream_from "conversation_channel"</code> ? And where should I pass the parameters?</p>
  
  <p><strong>This is the Channel</strong></p>
  
  <pre><code>class ConversationChannel &lt; ApplicationCable::Channel
    def subscribed
      stream_from "conversation_channel"
    end
    def unsubscribed
    end
    def speak (data)
      Message.create! content: data["message"]
    end
  end
  </code></pre>
  
  <p><strong>This is the Job</strong></p>
  
  <pre><code>class ConversationBroadcastJob &lt; ApplicationJob
    queue_as :default
  
    def perform(message)
      ActionCable.server.broadcast 'conversation_channel', message: render_message(message)
    end
  
    private
    def render_message(message)
      ApplicationController.renderer.render(partial: 'messages/message', locals: {message: message})
    end
  end
  </code></pre>
  
  <p><strong>This is the client-side Coffeescript</strong></p>
  
  <pre><code>App.conversation = App.cable.subscriptions.create "ConversationChannel",
  
    connected: -&gt;
    disconnected: -&gt;
    received: (data) -&gt;
      $('#messages').append data['message']
    speak: (message) -&gt;
      @perform 'speak', message: message
  
    $(document).on 'keypress', '[data-behavior~=conversation_speaker]', (event) -&gt;
      if event.keyCode is 13
        App.conversation.speak event.target.value
        event.preventDefault()
  </code></pre>
  
  <p>And one last question, is this the path for the ActiveCable to work properly?</p>
  
  <p><code>coffeeScript -&gt; Channel -&gt; Model -&gt; Job -&gt; CoffeeScript</code>?</p>
  
  <p>Thank you for your help.</p>