0

I tried uninstalling Rails 4.1.5 by doing "gem uninstall rails" and then installing Rails 4.0.8 by doing "gem install rails --version 4.0.8". However, now when I try to see what version of Rails I am using by doing "rails -v" I still get "Rails 4.1.5". How do I fix this?

user3543006
  • 83
  • 1
  • 1
  • 7
  • Are you trying to switch an existing Rails project from 4.1.5 to 4.0.8? Or is it just system-wide `rails` command? – D-side Aug 27 '14 at 21:46
  • System-wide. I know I can specify which rails version to use for a new project, but I just want to be able to use 4.0.8 by default for all new projects. – user3543006 Aug 27 '14 at 21:49
  • possible duplicate of [RoR - How to remove Rails 4.1.1 version?](http://stackoverflow.com/questions/23748388/ror-how-to-remove-rails-4-1-1-version) – Brad Werth Aug 28 '14 at 03:40

1 Answers1

0

I know I'm a bit late however I am answering in case others need an answer of how to manage gem versions. The linked duplicate question offers a perfectly fine answer to the question but does not give guidance to how to easily manage this long term. I do the following before starting every new project.

First you need rvm to manage ruby versions and create gemsets. With gemsets you can create isolated groups of gems that are project or ruby or rails version specific (it's up to you how you organize yourself).

After installing a version of ruby to use you create a gemset and tell your system to use this version of ruby with this gemset.

Then select the gemset and install the version of rails you want to use into the gemset. You will also need to install bundler into the gemset.

Once you have this setup you can insert the following lines into your rails gem file to tell this project which ruby version, rails version and gemset to use (in my example I am using ruby version 2.1.5 with the gemset named scan and the rails version 4.0.8)

ruby '2.1.5'
#ruby-gemset=scan
gem 'rails', '4.0.8'

Then cd into the rails project directory and run bundle install. Bundler will install the gems from your project's gem file into the selected gemset. Now you have an isolated and stable system for the project. If you have another project with different ruby version, rails version and gemset any changes there will not affect anything here.

For more details on how to setup rvm just go to the website and read the documentation. It's really easy to use and will save you many headaches.

rorykoehler
  • 1,642
  • 2
  • 15
  • 20