When upgrading from Rails 4.2 to 5.1.4 is there a generator for Action Cable files?

I’ve recently upgraded my Rails 4.2 application to Rails 5.1.4, and I’m trying to work with Action Cable. I’ve been reading up on it a little and it seems that there are some files I’m currently missing such as, app/assets/javascripts/cable.js. Is there a rails generator to generate all of the “required” action cable default files such as cable.js. Or should I just work through the example here and add them as I go?

Thanks!

If you start a new application with Rails 5.1, you will get those files "for free" (automatically). If you upgrade an app, you should get them as well if you use the `rails upgrade` helper. There's a set of instructions for each version (subtle differences) in the Rails Guides site. Note that when you upgrade from one major version to another, the more recent upgrade scripts hide certain new features and changes behind feature flags, which you can disable one at a time as you work through the transition. Be sure you have a good set of unit and feature tests before you do this, and it should work according to plan.

Walter

Well I had followed this guide (unless I missed a step I’m unaware of) and ran the following commands

  • bundle update rails
  • rails app:update
    Which did perform updates to files in my bin/ and config/ directories. What is the actual helper method you are referring to for “rails upgrade”? I tried running that in my terminal but it error’d out so I’m guessing that it wasn’t meant for there. I’ll leave the error below in case it was intended for there.

For anyone else, I forgot to link the guide I was following… here. But what I eventually read on SO was I needed to add the files myself as rails didn’t create them. So I manually added the following:

  • app/assets/javascripts/cable.js
  • app/channels/application_cable/connection.rb
  • app/channels/application_cable/channel.rb

For anyone else, I forgot to link the guide I was following... here. But what I eventually read on SO was I needed to add the files myself as rails didn't create them. So I manually added the following:

  • app/assets/javascripts/cable.js
  • app/channels/application_cable/connection.rb
  • app/channels/application_cable/channel.rb

Well I had followed this guide (unless I missed a step I'm unaware of) and ran the following commands

  • bundle update rails
  • rails app:update
Which did perform updates to files in my bin/ and config/ directories. What is the actual helper method you are referring to for "rails upgrade"? I tried running that in my terminal but it error'd out so I'm guessing that it wasn't meant for there. I'll leave the error below in case it was intended for there.

No, I mis-remembered the name, you found the thing I was thinking of. I'm not sure why the update script didn't make the missing files. But glad you found the way to get them in there.

Walter