Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching between different version of rails in same gem set

I have installed two different version of rails in same gem set. When I do gem list rails it will show as follows:

      **rails (3.0.11, 2.3.8)** // This means I have two rails

When I create new rails application it will take latest one, that means app should be created using rails new app_name not using rails app_name.

But I want to use rails 2.3.8 instead of 3.0.11. I know that using RVM helps in switching between different version of rails but they are installed in different gem set. Is there any possibility to switch between different rails version in same gem set?

Thank you.

like image 324
Rahul Tapali Avatar asked Mar 18 '12 09:03

Rahul Tapali


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 use a specific version of a gem?

You can install a specific gem version with gem install [name] -v [version] and use it as [name] _[version]_ [command] [line] [args] .

How do I install multiple versions of Rails?

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. The only thing you'll want to do is gem install rails to get the latest version and create your new project with rails new myapp .

How do I change the Rails version in Rbenv?

By using the "RBENV_VERSION=1.9. 2-p290" prefix in your command line, you're specifying which ruby rbenv should be concerned with. Then following that with the "rbenv exec" command, you can install rails. Just use the version flag as in the example to specify which version you want.


2 Answers

The later version has higher precedence. You have to be explicit when create app by:

rails _3.0.11_ new my_app

OR

rails _2.3.8_ my_app

like image 64
Trung Lê Avatar answered Oct 18 '22 08:10

Trung Lê


I'm assuming you are not using Bundler if you are trying to use 2.3.8, so check your config/enrvironment.rb file and change the RAILS_GEM_VERSION to '2.3.8'

like image 1
johnnyx25 Avatar answered Oct 18 '22 08:10

johnnyx25