Skip to content

Instantly share code, notes, and snippets.

@shime
Created December 8, 2012 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shime/4241799 to your computer and use it in GitHub Desktop.
Save shime/4241799 to your computer and use it in GitHub Desktop.
Using multiple Rails and Ruby versions

This is the tutorial that explains you how to use different Rails and Ruby versions on your machines.

It assumes you're using Ruby Version Manager.

Creating Rails app

rails _<VESRION>_ new test_app

E.G.

rails _3.1.6_ new test_app

If you don't have that specific version installed, you will get an error. You can get a list of a rails versions with:

gem list rails

To install the missing Rails version use

gem install rails -v <VERSION>

NOTE: Rails 2 apps use rails test_app to create new app.

NOTE: Change directory to /tmp/ to create Rails apps inside your tmp directory (everything gets removed on shutdown). NO CLUTTER!

Using different Ruby versions

Rails versions depend on your currently used Ruby version. You can convince yourself this is true by checking out the RVM gems directory:

ls ~/.rmv/gems

There you'll see folders named like this:

RUBY_VERSION@GEMSET

Therefore, you are installing gems for the specific Ruby version you're using. This is also true for gemsets.

Bundler stuff

You can list the gems that are being currently used by your Rails app with

bundle list

To show where the specific gem is installed use

bundle show <GEM_NAME>

You can cd into the listed directory and browse that gem's source.

Rails command line tips

Check out the cool flags you can use with

rails -h

One of them is --skip-bundle. Use it when you don't want to run bundle install when generating the app directory. Let's assume you will be adding Airbrake or Exceptional to the Gemfile, so this will save you from running bundle install two times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment