Choosing a Rails Version

Choose the best Rails version according to your requirements

We'll cover the following

Overview

The previous instructions helped you install the version of Rails used by the examples in this course. Occasionally, we might not want to run that version, though. For example, a newer version with some fixes or new features might become available,. Or perhaps we’re developing on one machine but intending to deploy on another machine that contains a version of Rails that we don’t have any control over.

If either of these situations applies, we need to be aware of a few things. For starters, we can use the gem command to find out all the versions of Rails we’ve installed:

$ gem list --local rails

We can also verify which version of Rails we’re running as the default by using the rails --version command. It should return 6.0.1.

If it doesn’t, insert the version of Rails surrounded by underscores before the first parameter of any rails command. Here’s an example:

$ rails _6.0.1_ --version

This is particularly handy when you create a new application. Once you create an application with a specific version of Rails, it’ll continue to use that version of Rails, even if newer versions are installed on the system, until we decide it’s time to upgrade. To upgrade, simply update the version number in the Gemfile that’s in the root directory of the application and run bundle install.

Get hands-on with 1400+ tech skills courses.