-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction_cable_overview.html
943 lines (859 loc) · 51.9 KB
/
action_cable_overview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Action Cable Overview — Ruby on Rails Guides</title>
<link rel="stylesheet" type="text/css" href="stylesheets/style.css" data-turbolinks-track="reload">
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
<link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shCore.css" data-turbolinks-track="reload">
<link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shThemeRailsGuides.css" data-turbolinks-track="reload">
<link rel="stylesheet" type="text/css" href="stylesheets/fixes.css" data-turbolinks-track="reload">
<link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<script src="javascripts/syntaxhighlighter.js" data-turbolinks-track="reload"></script>
<script src="javascripts/turbolinks.js" data-turbolinks-track="reload"></script>
<script src="javascripts/guides.js" data-turbolinks-track="reload"></script>
<script src="javascripts/responsive-tables.js" data-turbolinks-track="reload"></script>
<meta property="og:title" content="Action Cable Overview — Ruby on Rails Guides" />
<meta name="description" content="Action Cable OverviewIn this guide, you will learn how Action Cable works and how to use WebSockets to incorporate real-time features into your Rails application.After reading this guide, you will know: What Action Cable is and its integration backend and frontend How to setup Action Cable How to setup channels Deployment and Architecture setup for running Action Cable" />
<meta property="og:description" content="Action Cable OverviewIn this guide, you will learn how Action Cable works and how to use WebSockets to incorporate real-time features into your Rails application.After reading this guide, you will know: What Action Cable is and its integration backend and frontend How to setup Action Cable How to setup channels Deployment and Architecture setup for running Action Cable" />
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="Ruby on Rails Guides" />
<meta property="og:image" content="https://avatars.githubusercontent.com/u/4223" />
<meta property="og:type" content="website" />
</head>
<body class="guide">
<div id="topNav">
<div class="wrapper">
<strong class="more-info-label">공식 웹사이트 <a href="https://rubyonrails.org/">rubyonrails.org:</a> </strong>
<span class="red-button more-info-button">
루비온레일스 웹사이트
</span>
<ul class="more-info-links s-hidden">
<li class="more-info"><a href="https://weblog.rubyonrails.org/">블로그</a></li>
<li class="more-info"><a href="https://guides.rubyonrails.org/">영문가이드</a></li>
<li class="more-info"><a href="https://api.rubyonrails.org/">레일스API</a></li>
<li class="more-info"><a href="https://stackoverflow.com/questions/tagged/ruby-on-rails">질문하기</a></li>
<li class="more-info"><a href="https://github.com/rails/rails">GitHub에서 기여하기</a></li>
</ul>
</div>
</div>
<div id="header">
<div class="wrapper clearfix">
<h1><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></h1>
<ul class="nav">
<li><a class="nav-item" href="index.html">홈</a></li>
<li class="guides-index guides-index-large">
<a href="index.html" id="guidesMenu" class="guides-index-item nav-item">가이드 인덱스</a>
<div id="guides" class="clearfix" style="display: none;">
<hr />
<div class="guides-section-container">
<div class="guides-section">
<dt>시작하면서</dt>
<dd><a href="getting_started.html">레일스로 시작하기</a></dd>
</div>
<div class="guides-section">
<dt>모델</dt>
<dd><a href="active_record_basics.html">액티브 레코드 기본</a></dd>
<dd><a href="active_record_migrations.html">액티브 레코드 마이그레이션</a></dd>
<dd><a href="active_record_validations.html">액티브 레코드 유효성 검증</a></dd>
<dd><a href="active_record_callbacks.html">액티브 레코드 콜백</a></dd>
<dd><a href="association_basics.html">Active Record Associations</a></dd>
<dd><a href="active_record_querying.html">Active Record Query Interface</a></dd>
</div>
<div class="guides-section">
<dt>Views</dt>
<dd><a href="layouts_and_rendering.html">Layouts and Rendering in Rails</a></dd>
<dd><a href="form_helpers.html">Action View Form Helpers</a></dd>
</div>
<div class="guides-section">
<dt>Controllers</dt>
<dd><a href="action_controller_overview.html">Action Controller Overview</a></dd>
<dd><a href="routing.html">Rails Routing from the Outside In</a></dd>
</div>
<div class="guides-section">
<dt>Other Components</dt>
<dd><a href="active_support_core_extensions.html">Active Support Core Extensions</a></dd>
<dd><a href="action_mailer_basics.html">Action Mailer Basics</a></dd>
<dd><a href="active_job_basics.html">Active Job Basics</a></dd>
<dd><a href="active_storage_overview.html">Active Storage Overview</a></dd>
<dd><a href="action_cable_overview.html">Action Cable Overview</a></dd>
</div>
<div class="guides-section">
<dt>Digging Deeper</dt>
<dd><a href="i18n.html">Rails Internationalization (I18n) API</a></dd>
<dd><a href="testing.html">Testing Rails Applications</a></dd>
<dd><a href="security.html">Securing Rails Applications</a></dd>
<dd><a href="debugging_rails_applications.html">Debugging Rails Applications</a></dd>
<dd><a href="configuring.html">Configuring Rails Applications</a></dd>
<dd><a href="command_line.html">The Rails Command Line</a></dd>
<dd><a href="asset_pipeline.html">The Asset Pipeline</a></dd>
<dd><a href="working_with_javascript_in_rails.html">Working with JavaScript in Rails</a></dd>
<dd><a href="autoloading_and_reloading_constants.html">Autoloading and Reloading Constants (Zeitwerk Mode)</a></dd>
<dd><a href="autoloading_and_reloading_constants_classic_mode.html">Autoloading and Reloading Constants (Classic Mode)</a></dd>
<dd><a href="caching_with_rails.html">Caching with Rails: An Overview</a></dd>
<dd><a href="api_app.html">Using Rails for API-only Applications</a></dd>
</div>
<div class="guides-section">
<dt>Extending Rails</dt>
<dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
<dd><a href="generators.html">Creating and Customizing Rails Generators & Templates</a></dd>
</div>
<div class="guides-section">
<dt>Contributions</dt>
<dd><a href="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</a></dd>
<dd><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dd>
<dd><a href="ruby_on_rails_guides_guidelines.html">Guides Guidelines</a></dd>
</div>
<div class="guides-section">
<dt>Policies</dt>
<dd><a href="maintenance_policy.html">Maintenance Policy</a></dd>
</div>
<div class="guides-section">
<dt>Release Notes</dt>
<dd><a href="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</a></dd>
<dd><a href="6_0_release_notes.html">Version 6.0 - August 2019</a></dd>
<dd><a href="5_2_release_notes.html">Version 5.2 - April 2018</a></dd>
<dd><a href="5_1_release_notes.html">Version 5.1 - April 2017</a></dd>
<dd><a href="5_0_release_notes.html">Version 5.0 - June 2016</a></dd>
<dd><a href="4_2_release_notes.html">Version 4.2 - December 2014</a></dd>
<dd><a href="4_1_release_notes.html">Version 4.1 - April 2014</a></dd>
<dd><a href="4_0_release_notes.html">Version 4.0 - June 2013</a></dd>
<dd><a href="3_2_release_notes.html">Version 3.2 - January 2012</a></dd>
<dd><a href="3_1_release_notes.html">Version 3.1 - August 2011</a></dd>
<dd><a href="3_0_release_notes.html">Version 3.0 - August 2010</a></dd>
<dd><a href="2_3_release_notes.html">Version 2.3 - March 2009</a></dd>
<dd><a href="2_2_release_notes.html">Version 2.2 - November 2008</a></dd>
</div>
</div>
</div>
</li>
<li><a class="nav-item" href="contributing_to_ruby_on_rails.html">기여하기</a></li>
<li class="guides-index guides-index-small">
<select class="guides-index-item nav-item">
<option value="index.html">가이드 인덱스</option>
<optgroup label="시작하면서">
<option value="getting_started.html">레일스로 시작하기</option>
</optgroup>
<optgroup label="모델">
<option value="active_record_basics.html">액티브 레코드 기본</option>
<option value="active_record_migrations.html">액티브 레코드 마이그레이션</option>
<option value="active_record_validations.html">액티브 레코드 유효성 검증</option>
<option value="active_record_callbacks.html">액티브 레코드 콜백</option>
<option value="association_basics.html">Active Record Associations</option>
<option value="active_record_querying.html">Active Record Query Interface</option>
</optgroup>
<optgroup label="Views">
<option value="layouts_and_rendering.html">Layouts and Rendering in Rails</option>
<option value="form_helpers.html">Action View Form Helpers</option>
</optgroup>
<optgroup label="Controllers">
<option value="action_controller_overview.html">Action Controller Overview</option>
<option value="routing.html">Rails Routing from the Outside In</option>
</optgroup>
<optgroup label="Other Components">
<option value="active_support_core_extensions.html">Active Support Core Extensions</option>
<option value="action_mailer_basics.html">Action Mailer Basics</option>
<option value="active_job_basics.html">Active Job Basics</option>
<option value="active_storage_overview.html">Active Storage Overview</option>
<option value="action_cable_overview.html">Action Cable Overview</option>
</optgroup>
<optgroup label="Digging Deeper">
<option value="i18n.html">Rails Internationalization (I18n) API</option>
<option value="testing.html">Testing Rails Applications</option>
<option value="security.html">Securing Rails Applications</option>
<option value="debugging_rails_applications.html">Debugging Rails Applications</option>
<option value="configuring.html">Configuring Rails Applications</option>
<option value="command_line.html">The Rails Command Line</option>
<option value="asset_pipeline.html">The Asset Pipeline</option>
<option value="working_with_javascript_in_rails.html">Working with JavaScript in Rails</option>
<option value="autoloading_and_reloading_constants.html">Autoloading and Reloading Constants (Zeitwerk Mode)</option>
<option value="autoloading_and_reloading_constants_classic_mode.html">Autoloading and Reloading Constants (Classic Mode)</option>
<option value="caching_with_rails.html">Caching with Rails: An Overview</option>
<option value="api_app.html">Using Rails for API-only Applications</option>
</optgroup>
<optgroup label="Extending Rails">
<option value="rails_on_rack.html">Rails on Rack</option>
<option value="generators.html">Creating and Customizing Rails Generators & Templates</option>
</optgroup>
<optgroup label="Contributions">
<option value="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</option>
<option value="api_documentation_guidelines.html">API Documentation Guidelines</option>
<option value="ruby_on_rails_guides_guidelines.html">Guides Guidelines</option>
</optgroup>
<optgroup label="Policies">
<option value="maintenance_policy.html">Maintenance Policy</option>
</optgroup>
<optgroup label="Release Notes">
<option value="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</option>
<option value="6_0_release_notes.html">Version 6.0 - August 2019</option>
<option value="5_2_release_notes.html">Version 5.2 - April 2018</option>
<option value="5_1_release_notes.html">Version 5.1 - April 2017</option>
<option value="5_0_release_notes.html">Version 5.0 - June 2016</option>
<option value="4_2_release_notes.html">Version 4.2 - December 2014</option>
<option value="4_1_release_notes.html">Version 4.1 - April 2014</option>
<option value="4_0_release_notes.html">Version 4.0 - June 2013</option>
<option value="3_2_release_notes.html">Version 3.2 - January 2012</option>
<option value="3_1_release_notes.html">Version 3.1 - August 2011</option>
<option value="3_0_release_notes.html">Version 3.0 - August 2010</option>
<option value="2_3_release_notes.html">Version 2.3 - March 2009</option>
<option value="2_2_release_notes.html">Version 2.2 - November 2008</option>
</optgroup>
</select>
</li>
</ul>
</div>
</div>
<hr class="hide" />
<div id="feature">
<div class="wrapper">
<h2>Action Cable Overview</h2><p>In this guide, you will learn how Action Cable works and how to use WebSockets to
incorporate real-time features into your Rails application.</p><p>After reading this guide, you will know:</p>
<ul>
<li>What Action Cable is and its integration backend and frontend</li>
<li>How to setup Action Cable</li>
<li>How to setup channels</li>
<li>Deployment and Architecture setup for running Action Cable</li>
</ul>
<div id="subCol">
<h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
<ol class="chapters">
<li><a href="#introduction">Introduction</a></li>
<li><a href="#terminology">Terminology</a></li>
<li><a href="#what-is-pub-sub">What is Pub/Sub</a></li>
<li>
<a href="#server-side-components">Server-Side Components</a>
<ul>
<li><a href="#server-side-components-connections">Connections</a></li>
<li><a href="#channels">Channels</a></li>
</ul>
</li>
<li>
<a href="#client-side-components">Client-Side Components</a>
<ul>
<li><a href="#client-side-components-connections">Connections</a></li>
</ul>
</li>
<li>
<a href="#client-server-interactions">Client-Server Interactions</a>
<ul>
<li><a href="#streams">Streams</a></li>
<li><a href="#broadcasting">Broadcasting</a></li>
<li><a href="#client-server-interactions-subscriptions">Subscriptions</a></li>
<li><a href="#passing-parameters-to-channels">Passing Parameters to Channels</a></li>
<li><a href="#rebroadcasting-a-message">Rebroadcasting a Message</a></li>
</ul>
</li>
<li>
<a href="#full-stack-examples">Full-Stack Examples</a>
<ul>
<li><a href="#example-1-user-appearances">Example 1: User Appearances</a></li>
<li><a href="#example-2-receiving-new-web-notifications">Example 2: Receiving New Web Notifications</a></li>
<li><a href="#more-complete-examples">More Complete Examples</a></li>
</ul>
</li>
<li>
<a href="#configuration">Configuration</a>
<ul>
<li><a href="#subscription-adapter">Subscription Adapter</a></li>
<li><a href="#allowed-request-origins">Allowed Request Origins</a></li>
<li><a href="#consumer-configuration">Consumer Configuration</a></li>
<li><a href="#worker-pool-configuration">Worker Pool Configuration</a></li>
<li><a href="#other-configurations">Other Configurations</a></li>
</ul>
</li>
<li>
<a href="#running-standalone-cable-servers">Running Standalone Cable Servers</a>
<ul>
<li><a href="#in-app">In App</a></li>
<li><a href="#standalone">Standalone</a></li>
<li><a href="#notes">Notes</a></li>
</ul>
</li>
<li><a href="#dependencies">Dependencies</a></li>
<li><a href="#deployment">Deployment</a></li>
<li><a href="#testing">Testing</a></li>
</ol>
</div>
</div>
</div>
<div id="container">
<div class="wrapper">
<div id="mainCol">
<h3 id="introduction"><a class="anchorlink" href="#introduction">1 Introduction</a></h3><p>Action Cable seamlessly integrates
<a href="https://en.wikipedia.org/wiki/WebSocket">WebSockets</a> with the rest of your
Rails application. It allows for real-time features to be written in Ruby in the
same style and form as the rest of your Rails application, while still being
performant and scalable. It's a full-stack offering that provides both a
client-side JavaScript framework and a server-side Ruby framework. You have
access to your full domain model written with Active Record or your ORM of
choice.</p><h3 id="terminology"><a class="anchorlink" href="#terminology">2 Terminology</a></h3><p>A single Action Cable server can handle multiple connection instances. It has one
connection instance per WebSocket connection. A single user may have multiple
WebSockets open to your application if they use multiple browser tabs or devices.
The client of a WebSocket connection is called the consumer.</p><p>Each consumer can in turn subscribe to multiple cable channels. Each channel
encapsulates a logical unit of work, similar to what a controller does in
a regular MVC setup. For example, you could have a <code>ChatChannel</code> and
an <code>AppearancesChannel</code>, and a consumer could be subscribed to either
or to both of these channels. At the very least, a consumer should be subscribed
to one channel.</p><p>When the consumer is subscribed to a channel, they act as a subscriber.
The connection between the subscriber and the channel is, surprise-surprise,
called a subscription. A consumer can act as a subscriber to a given channel
any number of times. For example, a consumer could subscribe to multiple chat rooms
at the same time. (And remember that a physical user may have multiple consumers,
one per tab/device open to your connection).</p><p>Each channel can then again be streaming zero or more broadcastings.
A broadcasting is a pubsub link where anything transmitted by the broadcaster is
sent directly to the channel subscribers who are streaming that named broadcasting.</p><p>As you can see, this is a fairly deep architectural stack. There's a lot of new
terminology to identify the new pieces, and on top of that, you're dealing
with both client and server side reflections of each unit.</p><h3 id="what-is-pub-sub"><a class="anchorlink" href="#what-is-pub-sub">3 What is Pub/Sub</a></h3><p><a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern">Pub/Sub</a>, or
Publish-Subscribe, refers to a message queue paradigm whereby senders of
information (publishers), send data to an abstract class of recipients
(subscribers), without specifying individual recipients. Action Cable uses this
approach to communicate between the server and many clients.</p><h3 id="server-side-components"><a class="anchorlink" href="#server-side-components">4 Server-Side Components</a></h3><h4 id="server-side-components-connections"><a class="anchorlink" href="#server-side-components-connections">4.1 Connections</a></h4><p><em>Connections</em> form the foundation of the client-server relationship. For every
WebSocket accepted by the server, a connection object is instantiated. This
object becomes the parent of all the <em>channel subscriptions</em> that are created
from there on. The connection itself does not deal with any specific application
logic beyond authentication and authorization. The client of a WebSocket
connection is called the connection <em>consumer</em>. An individual user will create
one consumer-connection pair per browser tab, window, or device they have open.</p><p>Connections are instances of <code>ApplicationCable::Connection</code>. In this class, you
authorize the incoming connection, and proceed to establish it if the user can
be identified.</p><h5 id="connection-setup"><a class="anchorlink" href="#connection-setup">4.1.1 Connection Setup</a></h5><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
end
private
def find_verified_user
if verified_user = User.find_by(id: cookies.encrypted[:user_id])
verified_user
else
reject_unauthorized_connection
end
end
end
end
</pre>
</div>
<p>Here <code>identified_by</code> is a connection identifier that can be used to find the
specific connection 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.</p><p>This example relies on the fact that you will already have handled authentication of the user
somewhere else in your application, and that a successful authentication sets a signed
cookie with the user ID.</p><p>The cookie is then automatically sent to the connection instance when a new connection
is attempted, and you use that to set the <code>current_user</code>. 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 unauthorized).</p><h4 id="channels"><a class="anchorlink" href="#channels">4.2 Channels</a></h4><p>A <em>channel</em> encapsulates a logical unit of work, similar to what a controller does in a
regular MVC setup. By default, Rails creates a parent <code>ApplicationCable::Channel</code> class
for encapsulating shared logic between your channels.</p><h5 id="parent-channel-setup"><a class="anchorlink" href="#parent-channel-setup">4.2.1 Parent Channel Setup</a></h5><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/application_cable/channel.rb
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
</pre>
</div>
<p>Then you would create your own channel classes. For example, you could have a
<code>ChatChannel</code> and an <code>AppearanceChannel</code>:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/chat_channel.rb
class ChatChannel < ApplicationCable::Channel
end
# app/channels/appearance_channel.rb
class AppearanceChannel < ApplicationCable::Channel
end
</pre>
</div>
<p>A consumer could then be subscribed to either or both of these channels.</p><h5 id="channels-subscriptions"><a class="anchorlink" href="#channels-subscriptions">4.2.2 Subscriptions</a></h5><p>Consumers subscribe to channels, acting as <em>subscribers</em>. Their connection is
called a <em>subscription</em>. Produced messages are then routed to these channel
subscriptions based on an identifier sent by the cable consumer.</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/chat_channel.rb
class ChatChannel < ApplicationCable::Channel
# Called when the consumer has successfully
# become a subscriber to this channel.
def subscribed
end
end
</pre>
</div>
<h3 id="client-side-components"><a class="anchorlink" href="#client-side-components">5 Client-Side Components</a></h3><h4 id="client-side-components-connections"><a class="anchorlink" href="#client-side-components-connections">5.1 Connections</a></h4><p>Consumers require an instance of the connection on their side. This can be
established using the following JavaScript, which is generated by default by Rails:</p><h5 id="connect-consumer"><a class="anchorlink" href="#connect-consumer">5.1.1 Connect Consumer</a></h5><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/consumer.js
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
import { createConsumer } from "@rails/actioncable"
export default createConsumer()
</pre>
</div>
<p>This will ready a consumer that'll connect against <code>/cable</code> on your server by default.
The connection won't be established until you've also specified at least one subscription
you're interested in having.</p><p>The consumer can optionally take an argument that specifies the URL to connect to. This
can be a string, or a function that returns a string that will be called when the
WebSocket is opened.</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// Specify a different URL to connect to
createConsumer('https://ws.example.com/cable')
// Use a function to dynamically generate the URL
createConsumer(getWebSocketURL)
function getWebSocketURL {
const token = localStorage.get('auth-token')
return `https://ws.example.com/cable?token=${token}`
}
</pre>
</div>
<h5 id="subscriber"><a class="anchorlink" href="#subscriber">5.1.2 Subscriber</a></h5><p>A consumer becomes a subscriber by creating a subscription to a given channel:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/chat_channel.js
import consumer from "./consumer"
consumer.subscriptions.create({ channel: "ChatChannel", room: "Best Room" })
// app/javascript/channels/appearance_channel.js
import consumer from "./consumer"
consumer.subscriptions.create({ channel: "AppearanceChannel" })
</pre>
</div>
<p>While this creates the subscription, the functionality needed to respond to
received data will be described later on.</p><p>A consumer can act as a subscriber to a given channel any number of times. For
example, a consumer could subscribe to multiple chat rooms at the same time:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/chat_channel.js
import consumer from "./consumer"
consumer.subscriptions.create({ channel: "ChatChannel", room: "1st Room" })
consumer.subscriptions.create({ channel: "ChatChannel", room: "2nd Room" })
</pre>
</div>
<h3 id="client-server-interactions"><a class="anchorlink" href="#client-server-interactions">6 Client-Server Interactions</a></h3><h4 id="streams"><a class="anchorlink" href="#streams">6.1 Streams</a></h4><p><em>Streams</em> provide the mechanism by which channels route published content
(broadcasts) to their subscribers.</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/chat_channel.rb
class ChatChannel < ApplicationCable::Channel
def subscribed
stream_from "chat_#{params[:room]}"
end
end
</pre>
</div>
<p>If you have a stream that is related to a model, then the broadcasting used
can be generated from the model and channel. The following example would
subscribe to a broadcasting like <code>comments:Z2lkOi8vVGVzdEFwcC9Qb3N0LzE</code></p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class CommentsChannel < ApplicationCable::Channel
def subscribed
post = Post.find(params[:id])
stream_for post
end
end
</pre>
</div>
<p>You can then broadcast to this channel like this:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
CommentsChannel.broadcast_to(@post, @comment)
</pre>
</div>
<h4 id="broadcasting"><a class="anchorlink" href="#broadcasting">6.2 Broadcasting</a></h4><p>A <em>broadcasting</em> is a pub/sub link where anything transmitted by a publisher
is routed directly to the channel subscribers who are streaming that named
broadcasting. Each channel can be streaming zero or more broadcastings.</p><p>Broadcastings are purely an online queue and time-dependent. If a consumer is
not streaming (subscribed to a given channel), they'll not get the broadcast
should they connect later.</p><p>Broadcasts are called elsewhere in your Rails application:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
WebNotificationsChannel.broadcast_to(
current_user,
title: 'New things!',
body: 'All the news fit to print'
)
</pre>
</div>
<p>The <code>WebNotificationsChannel.broadcast_to</code> call places a message in the current
subscription adapter's pubsub queue under a separate broadcasting name for each user.
The default pubsub queue for Action Cable is <code>redis</code> in production and <code>async</code> in development and
test environments. For a user with an ID of 1, the broadcasting name would be <code>web_notifications:1</code>.</p><p>The channel has been instructed to stream everything that arrives at
<code>web_notifications:1</code> directly to the client by invoking the <code>received</code>
callback.</p><h4 id="client-server-interactions-subscriptions"><a class="anchorlink" href="#client-server-interactions-subscriptions">6.3 Subscriptions</a></h4><p>When a consumer is subscribed to a channel, they act as a subscriber. This
connection is called a subscription. Incoming messages are then routed to
these channel subscriptions based on an identifier sent by the cable consumer.</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/chat_channel.js
// Assumes you've already requested the right to send web notifications
import consumer from "./consumer"
consumer.subscriptions.create({ channel: "ChatChannel", room: "Best Room" }, {
received(data) {
this.appendLine(data)
},
appendLine(data) {
const html = this.createLine(data)
const element = document.querySelector("[data-chat-room='Best Room']")
element.insertAdjacentHTML("beforeend", html)
},
createLine(data) {
return `
<article class="chat-line">
<span class="speaker">${data["sent_by"]}</span>
<span class="body">${data["body"]}</span>
</article>
`
}
})
</pre>
</div>
<h4 id="passing-parameters-to-channels"><a class="anchorlink" href="#passing-parameters-to-channels">6.4 Passing Parameters to Channels</a></h4><p>You can pass parameters from the client side to the server side when creating a
subscription. For example:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/chat_channel.rb
class ChatChannel < ApplicationCable::Channel
def subscribed
stream_from "chat_#{params[:room]}"
end
end
</pre>
</div>
<p>An object passed as the first argument to <code>subscriptions.create</code> becomes the
params hash in the cable channel. The keyword <code>channel</code> is required:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/chat_channel.js
import consumer from "./consumer"
consumer.subscriptions.create({ channel: "ChatChannel", room: "Best Room" }, {
received(data) {
this.appendLine(data)
},
appendLine(data) {
const html = this.createLine(data)
const element = document.querySelector("[data-chat-room='Best Room']")
element.insertAdjacentHTML("beforeend", html)
},
createLine(data) {
return `
<article class="chat-line">
<span class="speaker">${data["sent_by"]}</span>
<span class="body">${data["body"]}</span>
</article>
`
}
})
</pre>
</div>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# Somewhere in your app this is called, perhaps
# from a NewCommentJob.
ActionCable.server.broadcast(
"chat_#{room}",
sent_by: 'Paul',
body: 'This is a cool chat app.'
)
</pre>
</div>
<h4 id="rebroadcasting-a-message"><a class="anchorlink" href="#rebroadcasting-a-message">6.5 Rebroadcasting a Message</a></h4><p>A common use case is to <em>rebroadcast</em> a message sent by one client to any
other connected clients.</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/chat_channel.rb
class ChatChannel < ApplicationCable::Channel
def subscribed
stream_from "chat_#{params[:room]}"
end
def receive(data)
ActionCable.server.broadcast("chat_#{params[:room]}", data)
end
end
</pre>
</div>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/chat_channel.js
import consumer from "./consumer"
const chatChannel = consumer.subscriptions.create({ channel: "ChatChannel", room: "Best Room" }, {
received(data) {
// data => { sent_by: "Paul", body: "This is a cool chat app." }
}
}
chatChannel.send({ sent_by: "Paul", body: "This is a cool chat app." })
</pre>
</div>
<p>The rebroadcast will be received by all connected clients, <em>including</em> the
client that sent the message. Note that params are the same as they were when
you subscribed to the channel.</p><h3 id="full-stack-examples"><a class="anchorlink" href="#full-stack-examples">7 Full-Stack Examples</a></h3><p>The following setup steps are common to both examples:</p>
<ol>
<li>
<a href="#connection-setup">Setup your connection</a>.</li>
<li>
<a href="#parent-channel-setup">Setup your parent channel</a>.</li>
<li>
<a href="#connect-consumer">Connect your consumer</a>.</li>
</ol>
<h4 id="example-1-user-appearances"><a class="anchorlink" href="#example-1-user-appearances">7.1 Example 1: User Appearances</a></h4><p>Here's a simple example of a channel that tracks whether a user is online or not
and what page they're on. (This is useful for creating presence features like showing
a green dot next to a user name if they're online).</p><p>Create the server-side appearance channel:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/appearance_channel.rb
class AppearanceChannel < ApplicationCable::Channel
def subscribed
current_user.appear
end
def unsubscribed
current_user.disappear
end
def appear(data)
current_user.appear(on: data['appearing_on'])
end
def away
current_user.away
end
end
</pre>
</div>
<p>When a subscription is initiated the <code>subscribed</code> callback gets fired and we
take that opportunity to say "the current user has indeed appeared". That
appear/disappear API could be backed by Redis, a database, or whatever else.</p><p>Create the client-side appearance channel subscription:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/appearance_channel.js
import consumer from "./consumer"
consumer.subscriptions.create("AppearanceChannel", {
// Called once when the subscription is created.
initialized() {
this.update = this.update.bind(this)
},
// Called when the subscription is ready for use on the server.
connected() {
this.install()
this.update()
},
// Called when the WebSocket connection is closed.
disconnected() {
this.uninstall()
},
// Called when the subscription is rejected by the server.
rejected() {
this.uninstall()
},
update() {
this.documentIsActive ? this.appear() : this.away()
},
appear() {
// Calls `AppearanceChannel#appear(data)` on the server.
this.perform("appear", { appearing_on: this.appearingOn })
},
away() {
// Calls `AppearanceChannel#away` on the server.
this.perform("away")
},
install() {
window.addEventListener("focus", this.update)
window.addEventListener("blur", this.update)
document.addEventListener("turbolinks:load", this.update)
document.addEventListener("visibilitychange", this.update)
},
uninstall() {
window.removeEventListener("focus", this.update)
window.removeEventListener("blur", this.update)
document.removeEventListener("turbolinks:load", this.update)
document.removeEventListener("visibilitychange", this.update)
},
get documentIsActive() {
return document.visibilityState == "visible" && document.hasFocus()
},
get appearingOn() {
const element = document.querySelector("[data-appearing-on]")
return element ? element.getAttribute("data-appearing-on") : null
}
})
</pre>
</div>
<h6 id="client-server-interaction"><a class="anchorlink" href="#client-server-interaction">7.1.1 Client-Server Interaction</a></h6>
<ol>
<li><p><strong>Client</strong> connects to the <strong>Server</strong> via <code>App.cable =
ActionCable.createConsumer("ws://cable.example.com")</code>. (<code>cable.js</code>). The
<strong>Server</strong> identifies this connection by <code>current_user</code>.</p></li>
<li><p><strong>Client</strong> subscribes to the appearance channel via
<code>consumer.subscriptions.create({ channel: "AppearanceChannel" })</code>. (<code>appearance_channel.js</code>)</p></li>
<li><p><strong>Server</strong> recognizes a new subscription has been initiated for the
appearance channel and runs its <code>subscribed</code> callback, calling the <code>appear</code>
method on <code>current_user</code>. (<code>appearance_channel.rb</code>)</p></li>
<li><p><strong>Client</strong> recognizes that a subscription has been established and calls
<code>connected</code> (<code>appearance_channel.js</code>) which in turn calls <code>install</code> and <code>appear</code>.
<code>appear</code> calls <code>AppearanceChannel#appear(data)</code> on the server, and supplies a
data hash of <code>{ appearing_on: this.appearingOn }</code>. This is
possible because the server-side channel instance automatically exposes all
public methods declared on the class (minus the callbacks), so that these can be
reached as remote procedure calls via a subscription's <code>perform</code> method.</p></li>
<li><p><strong>Server</strong> receives the request for the <code>appear</code> action on the appearance
channel for the connection identified by <code>current_user</code>
(<code>appearance_channel.rb</code>). <strong>Server</strong> retrieves the data with the
<code>:appearing_on</code> key from the data hash and sets it as the value for the <code>:on</code>
key being passed to <code>current_user.appear</code>.</p></li>
</ol>
<h4 id="example-2-receiving-new-web-notifications"><a class="anchorlink" href="#example-2-receiving-new-web-notifications">7.2 Example 2: Receiving New Web Notifications</a></h4><p>The appearance example was all about exposing server functionality to
client-side invocation over the WebSocket connection. But the great thing
about WebSockets is that it's a two-way street. So now let's show an example
where the server invokes an action on the client.</p><p>This is a web notification channel that allows you to trigger client-side
web notifications when you broadcast to the right streams:</p><p>Create the server-side web notifications channel:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# app/channels/web_notifications_channel.rb
class WebNotificationsChannel < ApplicationCable::Channel
def subscribed
stream_for current_user
end
end
</pre>
</div>
<p>Create the client-side web notifications channel subscription:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
// app/javascript/channels/web_notifications_channel.js
// Client-side which assumes you've already requested
// the right to send web notifications.
import consumer from "./consumer"
consumer.subscriptions.create("WebNotificationsChannel", {
received(data) {
new Notification(data["title"], body: data["body"])
}
})
</pre>
</div>
<p>Broadcast content to a web notification channel instance from elsewhere in your
application:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# Somewhere in your app this is called, perhaps from a NewCommentJob
WebNotificationsChannel.broadcast_to(
current_user,
title: 'New things!',
body: 'All the news fit to print'
)
</pre>
</div>
<p>The <code>WebNotificationsChannel.broadcast_to</code> call places a message in the current
subscription adapter's pubsub queue under a separate broadcasting name for each
user. For a user with an ID of 1, the broadcasting name would be
<code>web_notifications:1</code>.</p><p>The channel has been instructed to stream everything that arrives at
<code>web_notifications:1</code> directly to the client by invoking the <code>received</code>
callback. The data passed as argument is the hash sent as the second parameter
to the server-side broadcast call, JSON encoded for the trip across the wire
and unpacked for the data argument arriving as <code>received</code>.</p><h4 id="more-complete-examples"><a class="anchorlink" href="#more-complete-examples">7.3 More Complete Examples</a></h4><p>See the <a href="https://github.com/rails/actioncable-examples">rails/actioncable-examples</a>
repository for a full example of how to setup Action Cable in a Rails app and adding channels.</p><h3 id="configuration"><a class="anchorlink" href="#configuration">8 Configuration</a></h3><p>Action Cable has two required configurations: a subscription adapter and allowed request origins.</p><h4 id="subscription-adapter"><a class="anchorlink" href="#subscription-adapter">8.1 Subscription Adapter</a></h4><p>By default, Action Cable looks for a configuration file in <code>config/cable.yml</code>.
The file must specify an adapter for each Rails environment. See the
<a href="#dependencies">Dependencies</a> section for additional information on adapters.</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://10.10.3.153:6381
channel_prefix: appname_production
</pre>
</div>
<h5 id="adapter-configuration"><a class="anchorlink" href="#adapter-configuration">8.1.1 Adapter Configuration</a></h5><p>Below is a list of the subscription adapters available for end users.</p><h6 id="async-adapter"><a class="anchorlink" href="#async-adapter">8.1.1.1 Async Adapter</a></h6><p>The async adapter is intended for development/testing and should not be used in production.</p><h6 id="redis-adapter"><a class="anchorlink" href="#redis-adapter">8.1.1.2 Redis Adapter</a></h6><p>The Redis adapter requires users to provide a URL pointing to the Redis server.
Additionally, a <code>channel_prefix</code> may be provided to avoid channel name collisions
when using the same Redis server for multiple applications. See the <a href="https://redis.io/topics/pubsub#database-amp-scoping">Redis PubSub documentation</a> for more details.</p><h6 id="postgresql-adapter"><a class="anchorlink" href="#postgresql-adapter">8.1.1.3 PostgreSQL Adapter</a></h6><p>The PostgreSQL adapter uses Active Record's connection pool, and thus the
application's <code>config/database.yml</code> database configuration, for its connection.
This may change in the future. <a href="https://github.com/rails/rails/issues/27214">#27214</a></p><h4 id="allowed-request-origins"><a class="anchorlink" href="#allowed-request-origins">8.2 Allowed Request Origins</a></h4><p>Action Cable will only accept requests from specified origins, which are
passed to the server config as an array. The origins can be instances of
strings or regular expressions, against which a check for the match will be performed.</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
config.action_cable.allowed_request_origins = ['https://rubyonrails.com', %r{http://ruby.*}]
</pre>
</div>
<p>To disable and allow requests from any origin:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
config.action_cable.disable_request_forgery_protection = true
</pre>
</div>
<p>By default, Action Cable allows all requests from localhost:3000 when running
in the development environment.</p><h4 id="consumer-configuration"><a class="anchorlink" href="#consumer-configuration">8.3 Consumer Configuration</a></h4><p>To configure the URL, add a call to <code>action_cable_meta_tag</code> in your HTML layout
HEAD. This uses a URL or path typically set via <code>config.action_cable.url</code> in the
environment configuration files.</p><h4 id="worker-pool-configuration"><a class="anchorlink" href="#worker-pool-configuration">8.4 Worker Pool Configuration</a></h4><p>The worker pool is used to run connection callbacks and channel actions in
isolation from the server's main thread. Action Cable allows the application
to configure the number of simultaneously processed threads in the worker pool.</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
config.action_cable.worker_pool_size = 4
</pre>
</div>
<p>Also, note that your server must provide at least the same number of database
connections as you have workers. The default worker pool size is set to 4, so
that means you have to make at least 4 database connections available.
You can change that in <code>config/database.yml</code> through the <code>pool</code> attribute.</p><h4 id="other-configurations"><a class="anchorlink" href="#other-configurations">8.5 Other Configurations</a></h4><p>The other common option to configure is the log tags applied to the
per-connection logger. Here's an example that uses
the user account id if available, else "no-account" while tagging:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
config.action_cable.log_tags = [
-> request { request.env['user_account_id'] || "no-account" },
:action_cable,
-> request { request.uuid }
]
</pre>
</div>
<p>For a full list of all configuration options, see the
<code>ActionCable::Server::Configuration</code> class.</p><h3 id="running-standalone-cable-servers"><a class="anchorlink" href="#running-standalone-cable-servers">9 Running Standalone Cable Servers</a></h3><h4 id="in-app"><a class="anchorlink" href="#in-app">9.1 In App</a></h4><p>Action Cable can run alongside your Rails application. For example, to
listen for WebSocket requests on <code>/websocket</code>, specify that path to
<code>config.action_cable.mount_path</code>:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# config/application.rb
class Application < Rails::Application
config.action_cable.mount_path = '/websocket'
end
</pre>
</div>
<p>You can use <code>ActionCable.createConsumer()</code> to connect to the cable
server if <code>action_cable_meta_tag</code> is invoked in the layout. Otherwise, A path is
specified as first argument to <code>createConsumer</code> (e.g. <code>ActionCable.createConsumer("/websocket")</code>).</p><p>For every instance of your server you create and for every worker your server
spawns, you will also have a new instance of Action Cable, but the use of Redis
keeps messages synced across connections.</p><h4 id="standalone"><a class="anchorlink" href="#standalone">9.2 Standalone</a></h4><p>The cable servers can be separated from your normal application server. It's
still a Rack application, but it is its own Rack application. The recommended
basic setup is as follows:</p><div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# cable/config.ru
require_relative '../config/environment'
Rails.application.eager_load!
run ActionCable.server
</pre>
</div>
<p>Then you start the server using a binstub in <code>bin/cable</code> ala:</p><div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
#!/bin/bash
bundle exec puma -p 28080 cable/config.ru
</pre>
</div>
<p>The above will start a cable server on port 28080.</p><h4 id="notes"><a class="anchorlink" href="#notes">9.3 Notes</a></h4><p>The WebSocket server doesn't have access to the session, but it has
access to the cookies. This can be used when you need to handle
authentication. You can see one way of doing that with Devise in this <a href="https://greg.molnar.io/blog/actioncable-devise-authentication/">article</a>.</p><h3 id="dependencies"><a class="anchorlink" href="#dependencies">10 Dependencies</a></h3><p>Action Cable provides a subscription adapter interface to process its
pubsub internals. By default, asynchronous, inline, PostgreSQL, and Redis
adapters are included. The default adapter
in new Rails applications is the asynchronous (<code>async</code>) adapter.</p><p>The Ruby side of things is built on top of <a href="https://github.com/faye/websocket-driver-ruby">websocket-driver</a>,
<a href="https://github.com/celluloid/nio4r">nio4r</a>, and <a href="https://github.com/ruby-concurrency/concurrent-ruby">concurrent-ruby</a>.</p><h3 id="deployment"><a class="anchorlink" href="#deployment">11 Deployment</a></h3><p>Action Cable is powered by a combination of WebSockets and threads. Both the
framework plumbing and user-specified channel work are handled internally by
utilizing Ruby's native thread support. This means you can use all your regular
Rails models with no problem, as long as you haven't committed any thread-safety sins.</p><p>The Action Cable server implements the Rack socket hijacking API,
thereby allowing the use of a multithreaded pattern for managing connections
internally, irrespective of whether the application server is multi-threaded or not.</p><p>Accordingly, Action Cable works with popular servers like Unicorn, Puma, and
Passenger.</p><h3 id="testing"><a class="anchorlink" href="#testing">12 Testing</a></h3><p>You can find detailed instructions on how to test your Action Cable functionality in the
<a href="testing.html#testing-action-cable">testing guide</a>.</p>
<h3>피드백</h3>
<p>
이 가이드의 품질을 향상시키기 위해 여러분의 도움이 필요하다.
</p>
<p>
오타나 실제 오류를 발견시 여러분의 기여를 권고한다. 시작하려면 본 <a href="https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation">가이드의 기여</a> 섹션을 읽어보기 바란다.
</p>
<p>
미완성된 컨텐츠나 업데이트되지 않은 내용을 발견할 수도 있다. 누락된 문서는 master 브랜치에 추가한다. 제시된 이슈들이 master 브랜치 상에서 이미 해결되었는지 여부를 확인하려면 먼저 <a href="https://edgeguides.rubyonrails.org">Edge Guides</a>를 확인한다. 스타일과 규칙에 대해서는 <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>을 확인한다.
</p>
<p>
어떤 이유로든 고칠 수 있지만 직접 패치 할 수 없는 경우 <a href="https://github.com/rails/rails/issues">이슈를 새로 오픈</a>하면 된다.
</p>
<p>
그리고 마지막으로, 루비온레일스 문서에 관한 모든 논의는 <a href="https://groups.google.com/forum/#!forum/rubyonrails-docs">rubyonrails-docs 메일링 리스트</a> 상에서 언제든지 가능하다.
</p>
</div>
</div>
</div>
<hr class="hide" />
<div id="footer">
<div class="wrapper">
<p>본 결과물은 <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a> 를 준수한다. </p>
<p>"Rails", "Ruby on Rails", 그리고 레일스 로고는 David Heinemeier Hansson의 등록상표이다. 판권 소유.</p>
</div>
</div>
</body>
</html>