Before proceeding, we assume you already have Ubuntu installed on your machine and provided with a valid administrator account (or an account with sudo capability). Here is the list of requirements for Ubuntu to install all of the following parts of Ruby on Rails:

  • Internet connection: to download and install necessary libraries and applications.
  • Sufficient system software: curl, nodejs, libmysqlclient-dev (required to use mysql2 gem), libpq-dev (required for pg gem). You can install those with command: sudo apt-get install app1 app2 … (e.g.: sudo apt-get install curl nodejs and provide your password).

Installing RVM

RVM is a Ruby Version Manager created by Wayne E. Seguin to ease the process of installing and managing many different versions of Ruby and gem sets on a single machine. Installing RVM is easy and we have a lot of options to do it (please refer to its installation documentation for more details). However, with the ruby or rails option included, the installation command will automatically install the latest Ruby or Rails version. Unfortunately, the most recent version of Ruby and Rails is largely different from the previous one and may cause problems to developers along the way. Thus we recommend installing the old version of Ruby on Rails. To start, you need to open a terminal (gnome-terminal, shortcut: Ctrl+Alt+T), call curl to download the script and then bash to install it, all in 1 command:

$ \curl -L https://get.rvm.io | bash -s stable -auto

The RVM environment is now added into .bash_profile file in your home directory, you need to load the environment by closing and reopening the terminal, or using the command:

$ . ~/.bash_profile

Last step is to install all system requirements for RVM to use, with only 1 command: rvm requirements If you are prompted for a password, just enter your account password and everything will be done automatically. That’s easy, right?

Installing Ruby and Rails

With RVM installed, you are ready to install Ruby on Rails. Now, this is the best part. Guess what? You only need 1 command for installing Ruby and 1 command for installing Rails. “Thank you very much Mr. Wayne!” On a terminal, enter this command to install Ruby (of version 1.9.3, latest of 1.x.x): rvm install 1.9.3 Want to check if installation is successful or not? Use this to see current version of Ruby: ruby -v Now for Rails (version 3.2.13, latest of 3.x.x), we do: gem install rails -v 3.2.13 As mysql2 and pg (for MySQL and PostgreSQL databases), are 2 most common used database gems, you may want to install it at this early stage. If so, enter these 2 commands in terminal: gem install mysql2 gem install pg Congratulations! You are now cool to begin developing you very first Ruby on Rails applications.

Installing PostgreSQL and MySQL

As mentioned above, (instead of SQLite,) you may need to use PostgreSQL and MySQL many times in the future for serious development. Thus, we present you the instructions to install those servers on your machine.

PostgreSQL

To install PostgreSQL server, use the following commands: sudo apt-get install postgresql sudo apt-get install postgresql-contrib You may need pgAdmin III (a GUI management tool) to easily manage your server and databases: sudo apt-get install pgadmin3 Now, you need to setup a password for your server. Use the following command to access psql interface for postgres database with postgres account (default username for your server): sudo -u postgres psql postgres Enter this command and provide your password of choice: \password postgres Now, exit psql interface with command \q and re-enter it: sudo -u postgres psql Then install adminpack extension: CREATE EXTENSION adminpack; And your PostgreSQL is ready for service. Please use the postgres username with the password you chose for your Rails applications!

MySQL

Installing MySQL is even easier, you just need to enter this command in terminal: sudo apt-get install mysql-server And there will be a script doing everything automatically for you. All you need to do is providing it with password for the root account of the server. Now you can develop Rails applications with mysql2 gem. Just remember to use root as username and the password is the password you entered in the installation! For managing, you may need to use the popular GUI tool named MySQL Workbench.

Beyond the scope

All basic stuff has been installed. “Now what?” You may pick a favorite editor and start developing some Rails projects. “But what types of editor can I use?” It depends on your interest and professional level:

  • For ease of development, you can use an IDE, such as Eclipse with a Ruby/Rails plugin or Aptana Studio.
  • For friendly look and better feel, you can use Textmate or Sublime Text (can be installed with Ubuntu Tweak
  • For ergonomic design (and maybe looking professional), you can use Vim (with support of many plugins, like rails.vim and snippets.vim).

For modeling PostgreSQL database, you can use pgModeler. There are a ton of great tools out there in the real world. You can always search for a collection of them that best fit your style and the projects you work on. That’s all we want to show you for your very first steps. Good luck on your Ruby on Rails journey and gem adventure!

As we cannot bring the whole world to you in just one single document, you have to look out-of-the-doc in case you are stuck or in need of information. Here is the links to resources that we have used to conduct and provide you this short and condensed installing guide:


Nguyễn Thanh Luân