Rails Noob's Notes

Because my memory is good but short.

RVM

Installation

This installation description is for Ubuntu.

Curl is needed to install RVM. In case the system doesn't have it:

sudo apt-get install curl

An installation of RVM doesn't require root privileges. RVM will install itself in a hidden .rvm directory in user's home directory.

gpg -keyserver hkp://keys.gnupg.net -recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

\curl -sSL https://get.rvm.io | bash -s stable

Now add this line to the ~/.bashrc file

source ~/.rvm/scripts/rvm

Then type that command (source ~/.rvm/scripts/rvm) or restart the terminal.

Install requirements. The system will ask for the password.

rvm requirements

You have installed RVM, but you don't have any Ruby installed inside RVM. You can check this with rvm list command.

To remove RVM from your system just delete ~/.rvm directory. Then delete the lines source ~/.rvm/scripts/rvm and export PATH="$PATH:$HOME/.rvm/bin" (created by heroku?) from ~/.bashrc.

Ruby versions management

rvm list - display list of installed Ruby versions (by RVM only).

rvm install 2.3.0 - install Ruby version 2.3.0.

rvm remove 2.2.1 - remove Ruby version 2.2.1.

rvm use 2.2.3 - use Ruby 2.2.3.

rvm use system - use Ruby installed by operating system.

rvm default - use default Ruby version.

rvm reset - set system Ruby as default.

rvm --default use 2.3.0 - set 2.3.0 to default and switch to it.

rvm docs generate - generate a documentation for the current Ruby interpreter.

rvm cleanup all - delete source files, archives etc. It saves disk space. The suorces are reqiured to generate documentation.

Gemsets management

rvm gemset list - display list of gemsets.

The global gemset shares gems to all gemsets for the current interpreter. The default gemset is used when no other gemset is selected.

rvm gemset list_all - display list of gemsets for all Ruby versions.

rvm current - display current Ruby version and current gemset. I don't know why this command is not in the manual.

rvm gemset create rails-test - create a new gemset named 'rails-test'.

rvm gemset delete rails-test - delete rails-test' gemset.

rvm gemset use rails-test - use 'rails-test' gemset.

rvm gemset use default - use default gemset.

rvm use 2.3.0@rails-test - shortcut for rvm use 2.3.0 then rvm gemset use rails-test.

rvm gemset rename rails-test rails-t - change 'rails-test' gemset name to 'rails-t'.

rvm use 2.3.0@rails-t --default - set 2.3.0@rails-t as a default gemset for each terminal session and switch to it.

rvm use --create 2.3.0@project - create 'project' gemset for 2.3.0 version of Ruby and switch to it.

rvm --ruby-version use 2.3.0@project - create two files: .ruby-version and .ruby-gemset. Do this in all your project directories. This makes you use automatically the proper version of Ruby and gemest in the project's directory.

Gems management

gem list - display list of gems for the current Ruby interpreter and gemset.

gem install bundler - install 'bundler' gem in the current gemset.

gem uninstall bundler - uninstall 'bundler' gem in the current gemset.

gem install rails -v 4.2.5 - install 'rails' gem version 4.2.5.

rvm @global do gem install bundler - install 'bundler' gem in the global space (all gemsets) for the current Ruby interpreter.

Problems

"Warning! PATH is not properly set up,"... blah, blah, blah.

Move the source ~/.rvm/scripts/rvm line to the end of the .bashrc file. Restart the terminal.