In the previous lecture we saw how to install Rails 6 (or the latest version of Rails) and then use it to create a new Rails applications.

At times you may need to work with specific versions of Rails which aren't the latest version or the default version in your system. In these cases you'll need to do two things.

1. Install the version of Rails that you want

2. Use this installed version (instead of the default version) to create a new Rails app

Let's start with number 1 above. To install a specific version of rails, let's say Rails 5, version 5.2.4, you will need to pass in the version flag. For this case, you can use the following command followed by enter:

gem install rails -v 5.2.4

Once the installation is complete, you can check that rails 5.2.4 is listed among your rails gems by typing in gem list rails followed by enter.

gem list rails

Now, in order to create a new Rails 5 application using this specific version, you will need to specify it while issuing the rails new command like below followed by enter (otherwise it'll use the default version of Rails in your system).

rails _5.2.4_ new test_app

This will create a new rails app called test_app with Rails version 5.2.4

Good luck!