Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install different versions of Rails and keep the existing ones?

I had Rails 2.3.5 installed, and wanted to upgrade to 2.3.10 as a stepping stone to Rails 3. I thought running gem install rails -v=2.3.10 would install 2.3.10 and keep 2.3.5 as well. But now when I do rails -v, it only lists Rails 2.3.10. How can I install different versions of Rails and keep the existing ones?

like image 908
ben Avatar asked Oct 25 '10 00:10

ben


People also ask

How do I switch between rails versions?

To know all rails versions released, you check out on all rails versions. You can also do it with your terminal with the command line gem list rails --remote --all | grep "^rails " . I you want to install rails on another version of ruby, you need to switch version of ruby and re-install version of rails.

How do I see all rails versions?

To find out what the most recent Rails version is, use the command gem search rails | grep "^rails " .


1 Answers

gem list rails should show you all installed versions of Rails. You can specify which one you want each project to use in the config/environment.rb file.

Alternately (or "additionally"), look in to RVM (particularly the "gemset" function) for maintaining separate gem sets for each project.

Updated May 2017 Instead of RVM gemsets, best practice for managing gems in Rails projects (including the Rails gem itself) is to use Bundler. Bundler's Gemfile will list all the gems your project uses, and allows you to "pin" versions, so by changing the version pin for Rails and running bundle you can update your project to the new version.

<sarcasm>Now that I've said that, though, Bundler is probably on the way out to be replaced by something else. </sarcasm>

like image 152
pjmorse Avatar answered Oct 24 '22 18:10

pjmorse