1. Using RVM to Keep Things Simple

    When you working with Rails/Ruby sooner or later you will have a situation where  you need to have multiple rails projects with different rails / ruby versions

    Things get more complicated when you need to keep more than one ruby version in your computer like

    • ruby-1.8.7
    • ruby 1.9.2

    Coz if you are to work with rails 3 or above its often a recommended practice to go with ruby-1.9.2 

    Having several different gem versions makes your life a nightmare, specially when you execute commands like rake

    So what is the solution to have different ruby/rails versions, answer is RVM (Ruby Version Manager), And I believe all of you may have already heard lots of good about it.

    Yeah it is a cool tool, And I was using it ..ah… actually blindly until very recently I figure out how useful is GemSet concept in RVM

    So this post is entirely based on how you could create a gem set and how to use it, OK lets start…

    Lets say I have two rails projects

    1. A - using ruby1.8.7 and rails 2.3.8
    2. B - using ruby1.9.2 and rails 3.0

    So lets install ruby1.8.7

    in your command prompt execute

    rvm install 1.8.7
    Then create a GemSet - gemset is nothing but just a name which you could group your ruby  version and related gems
    Lets name our gem set rails2

    execute this command to create your gem set

    rvm gemset create rails2

    Ok now we can install rails which will be grouped under this GemSet, But before that we have to make this as default

    rvm use 1.8.7@rails2 —default

    Easy enough right, So lets install rails 2.3.8, and its nothing fancy

    gem install rails -v 2.3.8

    Ok done, now we will repeat the same process to ruby1.9.2
    rvm install 1.8.7

    I will create this gemset as rails3

    rvm gemset create rails3

    Now to install rails3 make the rails3 gemset as default

    rvm use 1.9.2@rails3 —default

    Then install rails

          gem install rails -v 3.0.0

    Done…

    so now running the projects is simple as, when you want  to run the project A, activate the rails2 gem set,

    rvm use 1.8.7@rails2 —default

    And when you want to run project B, simply activate rails3 gemset

    rvm use 1.9.2@rails3 —default

    ……

    This post is inspired by the following post, its worth reading it

    http://stjhimy.com/posts/10-five-quick-steps-to-set-up-rvm-with-rails-2-and-rails3

Notes

  1. keepthingssimple posted this