diff options
Diffstat (limited to 'guides/source/action_cable_overview.md')
-rw-r--r-- | guides/source/action_cable_overview.md | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/guides/source/action_cable_overview.md b/guides/source/action_cable_overview.md index 28578b3369..0c486bb96c 100644 --- a/guides/source/action_cable_overview.md +++ b/guides/source/action_cable_overview.md @@ -106,11 +106,11 @@ Then you would create your own channel classes. For example, you could have a **ChatChannel** and an **AppearanceChannel**: ```ruby -# app/channels/application_cable/chat_channel.rb +# app/channels/chat_channel.rb class ChatChannel < ApplicationCable::Channel end -# app/channels/application_cable/appearance_channel.rb +# app/channels/appearance_channel.rb class AppearanceChannel < ApplicationCable::Channel end ``` @@ -125,7 +125,7 @@ Incoming messages are then routed to these channel subscriptions based on an identifier sent by the cable consumer. ```ruby -# app/channels/application_cable/chat_channel.rb +# app/channels/chat_channel.rb class ChatChannel < ApplicationCable::Channel # Called when the consumer has successfully become a subscriber of this channel def subscribed @@ -182,7 +182,7 @@ Streams provide the mechanism by which channels route published content (broadcasts) to its subscribers. ```ruby -# app/channels/application_cable/chat_channel.rb +# app/channels/chat_channel.rb class ChatChannel < ApplicationCable::Channel def subscribed stream_from "chat_#{params[:room]}" @@ -549,12 +549,13 @@ You can change that in `config/database.yml` through the `pool` attribute. ### In App Action Cable can run alongside your Rails application. For example, to -listen for WebSocket requests on `/websocket`, mount the server at that path: +listen for WebSocket requests on `/websocket`, specify that path to +`config.action_cable.mount_path`: ```ruby -# config/routes.rb -Example::Application.routes.draw do - mount ActionCable.server => '/cable' +# config/application.rb +class Application < Rails::Application + config.action_cable.mount_path = '/websocket' end ``` |