Rails 5.2 sets Ruby version in Gemfile and adds .ruby-version file by default

For Ruby developers,
it’s common to switch between
multiple Ruby versions for multiple projects
as per the needs of the project.
Sometimes, the process of
going back and forth with multiple Ruby versions
could be frustrating for the developer.
To avoid this we add
.ruby-version files
to our projects so that
version manager tools
such as rvm, rbenv etc.
can easily determine which Ruby version
should be used for that particular project.

One other case that Rails developers
have to take care of is ensuring that
the Ruby version used to run Rails
by the deployment tools
is the one that is desired.
In order to ensure that we
add ruby version to Gemfile.
This will help bundler install dependencies
scoped to the specified Ruby version.

Good News! Rails 5.2 makes our work easy.

In Rails 5.2,
changes have been made
to introduce .ruby-version file
and also add the Ruby version to Gemfile
by default after creating an app.