How do I switch between the three different versions of rails I see in my gem list? I want to switch back to a slightly older version for my new app. Is there a terminal command?
-
Possible duplicate of [How do I "activate" a different version of a particular gem?](http://stackoverflow.com/questions/4373128/how-do-i-activate-a-different-version-of-a-particular-gem). Also usually, the version in the Gemfile.lock is used for each gem, but for Rails specifically I'm not quite sure. If you are using RVM, you can do that by creating different gemsets. – Tamer Shlash Nov 19 '16 at 04:39
2 Answers
You can make use of gemset for switching between rails different versions.
rvm gemset create rails4
rvm gemset use rails4
gem install rails -v 4.0.0
If you don't want to use gemset then you can directly do this:
rails _4.0.0_ new app
For more information check this https://rvm.io/gemsets/basics

- 536
- 5
- 15
I am assuming you have a list of versions of rails so you can create different different gemset with different rails version and use that gemset. See below bold commands ex-
rvm list (list of rvm ruby version)
rvm rubies
ruby-2.0.0-p648 [ i686 ]
ruby-2.2.0 [ i686 ]
=* ruby-2.3.3 [ i686 ]
rvm gemset list (list of all available gemsets)
gemsets for ruby-2.3.3 (found in /home/ruby/.rvm/gems/ruby-2.3.3)
=> (default)
global
rails4
rvm gemset create rails5
ruby-2.3.3 - #gemset created /home/ruby/.rvm/gems/ruby-2.3.3@rails5
ruby-2.3.3 - #generating rails5 wrappers........
rvm use @rails5 (already default selected rvm ruby-2.3.3)
or
rvm use ruby-2.3.3@rails5 (Explicitly rvm ruby selected for this gemset)
Using /home/ruby/.rvm/gems/ruby-2.3.3 with gemset rails5
So in this manner we can switch between different gemsets or rails via gemsets. Under the gemset you can install or use any rails version it will available alway within this gemset scope.

- 1
- 1

- 316
- 1
- 7
-
1This answer really helpful if anybody want to create and use gemset with specific version of rails and ruby. I appreciate for your answer. – Surendra Singh Feb 13 '17 at 07:04