diff options
author | Jon Moss <maclover7@users.noreply.github.com> | 2016-01-22 14:26:05 -0500 |
---|---|---|
committer | Jon Moss <maclover7@users.noreply.github.com> | 2016-01-22 14:26:05 -0500 |
commit | 9bb5f5fbe109331f8021ae141b7cd935f98eb1df (patch) | |
tree | f51abe7bc7efdce46ef196d061ebd87f5cb157d2 | |
parent | f6925137a4f974c46feb5351a95874717115c1cd (diff) | |
parent | 08ac76d1ad91d5b54d5616e1a397f360d02687a1 (diff) | |
download | rails-9bb5f5fbe109331f8021ae141b7cd935f98eb1df.tar.gz rails-9bb5f5fbe109331f8021ae141b7cd935f98eb1df.tar.bz2 rails-9bb5f5fbe109331f8021ae141b7cd935f98eb1df.zip |
Merge pull request #23201 from dkniffin/patch-1
Move ApplicationCable::Channel section of readme
-rw-r--r-- | actioncable/README.md | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/actioncable/README.md b/actioncable/README.md index 636f9935cf..74c88d1efe 100644 --- a/actioncable/README.md +++ b/actioncable/README.md @@ -66,6 +66,13 @@ end Here `identified_by` is a connection identifier that can be used to find the specific connection again or later. Note that anything marked as an identifier will automatically create a delegate by the same name on any channel instances created off the connection. +This relies on the fact that you will already have handled authentication of the user, and +that a successful authentication sets a signed cookie with the `user_id`. This cookie is then +automatically sent to the connection instance when a new connection is attempted, and you +use that to set the `current_user`. By identifying the connection by this same current_user, +you're also ensuring that you can later retrieve all open connections by a given user (and +potentially disconnect them all if the user is deleted or deauthorized). + Then you should define your `ApplicationCable::Channel` class in Ruby. This is the place where you put shared logic between your channels. @@ -77,13 +84,6 @@ module ApplicationCable end ``` -This relies on the fact that you will already have handled authentication of the user, and -that a successful authentication sets a signed cookie with the `user_id`. This cookie is then -automatically sent to the connection instance when a new connection is attempted, and you -use that to set the `current_user`. By identifying the connection by this same current_user, -you're also ensuring that you can later retrieve all open connections by a given user (and -potentially disconnect them all if the user is deleted or deauthorized). - The client-side needs to setup a consumer instance of this connection. That's done like so: ```coffeescript |