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?
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.
To find out what the most recent Rails version is, use the command gem search rails | grep "^rails " .
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With