This week, I upgraded a little demo application for my book Deployment from Scratch from Rails 6 to Rails 6.1. Since I showcase WebSockets with ActionCable and Redis, I needed to move the ActionCable CoffeeScript from Sprockets to Webpacker.
I started with dependencies. The original application could lose
webpacker gem in
gem 'webpacker', '~> 5.4'
Once I generated a new
Gemfile.lock, I could run a
webpacker:install tasks that creates many files (which I won’t get into here):
$ rails webpacker:install
In case you won’t see the new Webpacker tasks, make sure to delete the Rails cache:
$ rails tmp:cache:clear
It took me a while to realize why I don’t see this Webpacker Rake task.
All these requirements should now happen in the new
After I had my new
application.js ready, I changed
Then I updated the channels. I went from this:
To new channels structure with
And then I rewrote my original subscription file that looked like this:
At this point the all the new files are in place, I just had to go and delete the old
And remove it from the manifest (the second line):
Although it’s a small app with only one channel, you might find this useful if you didn’t move to Webpacker yet.
← BUY THE PRE-RELEASE
I am writing a complete guide on web application deployment. Ruby with Puma, Python with Gunicorn, NGINX, PostgreSQL, Redis, networking, processes, systemd, backups, and all your usual suspects. 23 chapters and 3 scripted demonstrations already available.