Last Updated on November 18, 2020 by Christopher G Mendla
Updating to Rails 5.2 has a couple of ‘gotchas’.
I have a portfolio site hosted on Digital Ocean. This is a demo of my rails code and a bit of a sandbox to try things out. I’m currently in between jobs (Thanks Covid and shutdowns). I can use this app to keep my skills sharp.
Before starting on the update, I created a snapshot of the server using Digital Ocean’s snapshot tool
I had previously tried updating to Rails 5.2 and the result was that it worked in development but crashed production. I was able to recover the site back to 5.1.7.
After I recovered the site and made sure everything was stable I tried the update again. I got the site back to Rails 5.1.7.
Running Rspec was throwing some deprecation warnings. I fixed the warnings I could and left an issue on my GitHub repo.
I updated the Puma and PG gems.
I always use Railsdiff when upgrading Rails. This keeps the code base clean and in sync with how it should look. I ran into a couple of files where the code in my app did not quite match the code in Railsdiff. That tool a little bit of analysis to see what should be changed.
Rails 5.2 has two major changes. The first is how it handles credentials and the second is how it handles storage. In addition there are a couple of other lesser changes.
Rails 5.2 uses a new credentialing system. That caused one of the issues as I didn’t have that quite right. I decided to keep the old credentials for now by keeping the secrets.yml file.
I added an issue to the repo to migrate that at a later time. The old credential system worked.
The other major change is the implementation of ActiveStorage to replace tools such as paperclip. For some reason that would throw an error in production. I removed the activestorage line from application.js and put another issue in the repo to revisit that.
The application doesn’t use the database at this time. I’m not sure if disabling activestorage would prevent the database from working or not.
There are changes to the testing support infrastructure. I got that running but have to revisit it.
One of the other changes involves using Yarn. I had to install Yarn in my development environment and on the server. That forced me to straighten out the sudo rights on both dev and production. That was something I had been putting aside.
As you can see, I used a sledgehammer to get the site to Rails 5.2. I probably wouldn’t do that in a ‘real’ application. My goal is to get to Rails 126.96.36.199 to fix a vulnerability in prior versions of Rails. As a one person team doing this on the side I have to prioritize where I spend my effort.
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.