ActionCable in JumpStart project
Hi!
Is there anything special I need to consider when using ActionCable in a project created with the JumpStart template?
I've followed several tutorials (e.g. "Action Cable ‘Hello World’ with Rails 5.1") about ActionCable, which work fine by themselves, but I can't transfer that learned knowledge in my JumpStart based project.
I'm mostly confused about the extra javascript folder in the /app
folder (vs. /app/assets
). None of my coffee scripts in /app/assets/javascript/channels
created by the rails generator get initialized. Also I don't see the /cable
route getting started.
It would be great if someone could point me in the right direction or give me the most simple example of how to work with ActionCable in a JumpStart based project as I assume this can't be very hard.
Thanks in advance,
Stefan
Hey Stefan!
Everything is basically exactly the same, except that your Javascript is now in app/javascript
instead.
The easiest way to setup a channel is just to run the rails generate for it:
rails g channel MyChannel
And it will take care of creating the files for you.
You can read about the JS stuff here in the edge guides:
https://edgeguides.rubyonrails.org/action_cable_overview.html#client-side-components