William Notowidagdo Kiranatama Staff
Knowledge


We'll show a quick step-by-step to getting started with rvm on a new Rails application setup (in Ubuntu 10.04). Install rvm You'll need Git and cURL
$ sudo apt-get install git-core curl
now cd to your home directory and install rvm from there
$ bash < <( curl https://rvm.beginrescueend.com/releases/rvm-install-head )
then add this to your ~/.bash_profile, at the end of the file
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
test rvm installation
$ type rvm | head -1
if everything so far goes well, you should see
rvm is a function
Install rubies Before installing any of the Rubies, you want to install the required libraries first
$ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
now let's have ruby 1.8.7 as our first addition the our rubies
$ rvm install 1.8.7
then activate ruby 1.8.7 as our default
$ rvm --default use 1.8.7
test your installation with
$ ruby -v
you should see
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-linux]
now let's add ruby 1.9.2
$ rvm install 1.9.2
use and test 1.9.2 installation like we tested 1.8.7 Using .rvmrc Now let's create a directory that will hold your Rails app and create .rvmrc file there
$ mkdir awesomeapp
$ echo "rvm 1.9.2@awesomeapp" > awesomeapp/.rvmrc
$ cd awesomeapp
answer the question with 'y' and create the gemset and reload rvm
$ rvm gemset create 'awesomeapp'
$ rvm reload
then
$ gem env gemdir
should give you
/home/username/.rvm/gems/ruby-1.9.2-p136@awesomeapp
Create a Rails application From your 'awesomeapp' directory
$ gem install rails
$ rails new .
$ bundle install
Test your Rails app
$ rails server
and go to http://localhost:3000/ on your browser. If you see Rails default home page then you are good to go to code your next awesome Rails app. Summary Using rvm you can work with many rubies. You can work on one app using ruby 1.8.7 and another app with 1.9.2 also test your ready to deploy application using ree. By creating .rvmrc file in every project directory you can manage your gem installation easier. No more gem conflict between app.