Ask A Question

Notifications

You’re not receiving notifications from this thread.

ActionCable in JumpStart project

Stefan Dippl asked in Rails

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/channelscreated 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

Reply

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

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.