How to install Ruby on Rails in Ubuntu

Ruby on Rails is an application stack that provides developers with a framework to quickly create a variety of web applications.
so, how to use it?
very easy,please follow these steps is install and use it.

step 1. Install git and cURL

First of all, update your package repository.

1

sudo apt-get update

git is a simple, fast and efficient version control system. It is easy to learn, so even if you don’t have any experience with git you can try it in your next rails project (or any other project). you will love it.

1

sudo apt-get install git

Curl is a simple command line utility for getting file over web protocols, based on libcurl. To install curl simply execute –

1

sudo apt-get install curl

step 2. Install RVM and Dependencies

RVM is not strictly required but it makes ruby management a lot easier. You can try different implementations of ruby, different versions of ruby and all without any pain. So it’s strongly recommended. but RVM requires the command to be executed as login shell, so open a terminal and go to Edit -> Profile Preferences -> Title and Command and check the box that says “Run Command as a login shell“. (look at the above snapshot)

Installing Javascript Runtime

In newer version of Rails, you also need a Javascript runtime. Although you could install it from the package repository but it’s very outdated. So I recommend installing it using the PPA. (and I’ll also update the script)

1

2

3

sudo apt-add-repository ppa:chris-lea/node.js

sudo apt-get update

sudo apt-get install nodejs

step 3. Install Ruby

Now, you got RVM running, installing and running multiple versions or just one version of Ruby is very simple. To install Ruby just pass the version number to rvm install command (or some other implementation of ruby if you want; RVM also supports rbx, ree, JRuby, IRonRuby other than the default MRI) –

1

rvm install1.9.3

Then select the Ruby version you want to use, (or make it default so that you don’t have to select it again in new session)

1

rvm use1.9.3--default

Now, you can check the version of ruby, you’re running right now-

1

ruby-v

step 4. Install Rails

RVM installs ruby as well as the gem utility (managing ruby libraries). To install rails, simply install it using the gem. It will automatically install the latest version unless you specify the version explicitly.