How to upgrade to Rails 6?

Hello! You’re probably here because you want to know how to upgrade to Rails 6 during it’s beta phase, but can’t find a good guide for it. Well, here’s one for you!

Quick Explination

It might not be obvious, especially if you haven’t upgraded rails before, but all you need to do is change the text in your gemfile, and run bundle update

It’s that simple!

Longer Explination

Step 1

First, find out what the latest version of the Rails gem is. You can do this over on RailsGems.org

https://rubygems.org/gems/rails

We can see here that the Release Candidate (A polished version before the full release) was released today. Copy that version number, and add it to your gemfile.

Great!

Step 2

Go run bundle update. It might take a few minutes, especially as there’s some new gems Rails 6 is dependant on.

There’s Rails 6!

Step 3

Now that bundle has updated, go ahead and give Rails a run!

This is a good time to check the release notes to see what major (and potentially breaking) changes have been made since the previous version.

Rails 6 Release Notes

You’ll also want to run any test cases you’ve set up, or click around to check everything’s still working.

For example, I didn’t have many problems after updating from Rails 5 to Rails 6, but I did run into a problem with rendering a html partial inside an escape_javascript block. For some reason Rails 5 was happy with this, but Rails 6 expected the partial to be in the js format.

I fixed it by explicitly setting the format to html, and now everything’s working fine.

That’s all. Happy Rail-ing!

Share Your Thought