Actioncable-examples is outdated and needs refresh

There’s a repository for ActionCable demo. GitHub - rails/actioncable-examples: Action Cable Examples It’s linked from the guide

However, in some points, it’s getting outdated and needs refresh.

  1. It uses CoffeeScript, which is not a default language anymore for Rails 6.
  2. It uses cable.js file, which is not generated with Channel generator by Rails 6 any more.
  3. It uses jquery-rails, which is also not included by default in Rails 6.
  4. And most importantly, Rails version is 5,1.

Also I found the problem that although it’s mentioned as “complete” example, it doesn’t cover the whole usage the guide mentions.

I’d suggest adding new demo application for Rails 6 alongside the existing one. That’s mainly because things generated by a channel generator are quite different from older versions.

Any ideas?

5 Likes

I am on Rails 6, and found myself mentally translating CoffeeScript to JavaScript. Does it need to be seperate, or can it live on a branch for Rails 5, 6, and 7? Same app, just three versions? Nice to help you compare versions to figure out your own upgrade path.

Now I don’t think this example repository should exist in purpose of documentation. It’s hard to maintain it, and there are so many others ways to use ActionCable (e.g. my team uses it with React Hooks). If we have OSS Rails applications that use ActionCable, we can just point them as references. I looked at Discourse, Mastodon and Forem but none of them use it, so maybe no luck?

What about making a pull request on that repository? I’m pretty sure they would accept your changes

Basically I need to change all the things including the language (from CoffeeScript to the latest ES or TypeScript) and yet it’s not comprehensive enough. That’s why I don’t find it valuable.

There’s an online translator coffee to js

1 Like

Funny you should mention it, I’m trying to figure out why broadcasts work from the controller but don’t get appended to the relevant dom element and I don’t get any console logs from onConnect() and so I thought maybe the problem was there’s no cable.js file