Advantages of RVM,
1. You can shift between multiple versions of Ruby easily.
2. You don't have to worry about install Ruby dependencies. RVM install will take care of installing them. Some of the ruby dependencies are : gawk, autoconf, automake, bison, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, libyaml-dev, pkg-config, sqlite3, zlib1g-dev, libgmp-dev, libreadline6-dev, libssl-dev
3. Easily upgrade Ruby version and try out a latest version to make sure your project works with the latest Ruby. If something breaks, changing the version is easy.
4. Delete unwanted Ruby version anytime :)
Installation steps.
Step 1. Install RVM
Source : https://rvm.io/rvm/install
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
$ source /etc/profile
$ source ~/.rvm/scripts/rvm
$ type rvm | head -n 1 (this command returns 'rvm is a function' )
\curl -sSL https://get.rvm.io | bash -s stable
$ source /etc/profile
$ source ~/.rvm/scripts/rvm
$ type rvm | head -n 1 (this command returns 'rvm is a function' )
Step 2. Install Ruby
To List all known Ruby versions by rvm
$ rvm list known
From the list, pick a version and install ruby
$ rvm install ruby-2.3.7
Step 3. Install Rails
Rails is a Ruby gem. I always install bundler gem along with rails installation because it will be used in all Rails application to install dependencies
$ gem install bundler
$ gem install rails
$ gem install rails
Step 4. check version and start a project
# To check the Ruby version
$ ruby -v
$ ruby -v
# to check the Rails version
$ rails -v
# to start a new rails project with Mysql database. Rails by default uses sqlite. If you want to use any other database you will have to specify the adapter in config/database.yml
$ rails new project_name -d mysql
# Go inside the new project
$ cd project_name
# to install the dependencies
$ bundle install
# To start the server
$ rails s
http://localhost:3000
No comments:
Post a Comment