Now that ruby is installed, you will be able to install Rails on your server and then run your application, right?
Wrong! There is still, a major piece remaining.
Rails requires bundler to be installed so that when you deploy, the Gemfile in your project is automatically read and new Gems installed (if had added them, and you probably will)! To install bundler, make sure you have selected the right ruby in your terminal using
rbenv shell <version_number> and then run:
gem install bundler
Once the installation succeeds, you should run:
bundle help install
and that should print the installation help - and that means bundler is installed!
Install Ruby on Rails
You probably already know about it, but Rails is just another Ruby Gem. To install Rails, run the following command.
Note that we use
gem command here, not the
gem install rails
That will install the latest version of Ruby on Rails on the machine. However, that is not always desired. You might be using an earlier version of Rails. To install the specific version of Rails, run this:
gem install rails -v 5.1
That will install Ruby on Rails version 5.1
Tip - how to know which rails version you are on
If you followed a tutorial and now are not sure which version of Rails you are on, go to your project directory on Terminal and run
rails console command. The output should look similar to:
$ rails console Running via Spring preloader in process 7917 Loading development environment (Rails 5.2.1) irb(main):001:0>
Notice the line
Loading development environment (Rails 5.2.1). You have your rails version here. You can use this version number with
gem install command, like so:
gem install rails 5.2.1.