Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use RVM and different versions of rails

Hi I am beginner to ruby on rails. I have following this on my machine

nilkash@nilkash:~$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]
nilkash@nilkash:~$ rails -v
Rails 3.2.3
nilkash@nilkash:~$ rvm -v

rvm 1.19.6 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]

nilkash@nilkash:~$ rvm list

rvm rubies

=* ruby-1.9.3-p392 [ i686 ]

# => - current
# =* - current && default
#  * - default

nilkash@nilkash:~$ rvm gemset list

gemsets for ruby-1.9.3-p392 (found in /home/nilkash/.rvm/gems/ruby-1.9.3-p392)
   (default)
   global
   latest_rails_stable
=> rails3tutorial2ndEd 

I also install rails version 4.0.0. But I don't know how to use different versions of rails. when i create new project it shows rails version 3.x. I want to upgrade it to version 4. How to check list of all installed rails and how to use latest one. Need Help. Thank you.

like image 211
nilkash Avatar asked Aug 21 '13 03:08

nilkash


People also ask

How do I use different versions of rails?

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 change the rails version of RVM?

You can switch between the Ruby versions by typing: rvm use 3.0. 0.

How do I get multiple rails versions?

Every Rails project has the version of Rails in the Gemfile that it will use separately from every other app. There's nothing you need to do to manage two different Rails versions.


2 Answers

I also install rails version 4.0.0. But I don't know how to use different versions of rails. when i create new project it shows rails version 3.x. I want to upgrade it to version 4. How to check list of all installed rails and how to use latest one. Need Help. Thank you.

this is because you're still using the current gemset rails3tutorial2ndEd

You need to create a different gemset:

rvm gemset create <new_gemset_name>

then use it:

rvm gemset use <new_gemset_name>

and finally install a new rails version:

gem install rails -v <version_number>

only after doing these things will you be able to make a new project with a different rails version.

like image 98
roninblade Avatar answered Oct 16 '22 12:10

roninblade


If you want to only do a quick command in different rails version you can do:

 $ rails _4.0.1_ new MyRailsApp

That way you don't have some gems installed twice as you do when you use gem sets. Bundler should handle the rest so you should only need one gemset.

like image 21
Mab879 Avatar answered Oct 16 '22 12:10

Mab879