Iggy
Iggy

Reputation: 5251

How to switch back to Rails 5 once the version has been changed?

I can't believe I could not figure this out and I have been spending needlessly too long. I used to use rails v. 5.0.0.1. Somehow when I was cloning apps from railscasts, I switched my rails to 3.1.0. Ever since then everytime I do rails new myApp it created rails v. 3.1.0..

I have a project folder name Project where I store all my rails app. When I typed rails -v in that Project folder, I get

Projects iggy$ rails -v
Rails 3.1.0

I just created new app named demo (rails new demo), and it generated a new app with rails 3.1.0.

When I do gem list, this is what I got:

demo iggy$ gem list --local rails

*** LOCAL GEMS ***

autoprefixer-rails (6.5.3, 6.4.1, 6.4.0.2, 6.3.7, 6.3.6, 6.3.1)
coffee-rails (4.2.1, 4.1.1, 4.1.0, 3.1.1)
factory_girl_rails (4.7.0, 4.6.0, 4.5.0)
haml-rails (0.9.0)
jquery-rails (4.2.1, 4.1.1, 4.1.0, 4.0.4, 3.1.4)
less-rails (2.7.1)
pry-rails (0.3.4)
rails (5.0.0.1, 5.0.0, 4.2.7.1, 4.2.5, 4.2.4, 4.2.3, 3.1.0)

I have tried going to my app that uses rails 5, ran bundle update / bundle install, but whenever I go to Project folder, it always defaults back to rails 3.1.0. I use rvm.

How can I switch back to rails 5.0.0.1 so whenever I create new app it will use latest rails? Moreover in general, is it possible to seamlessly switch between different version of rails app? If so, how can I do that?

Upvotes: 0

Views: 194

Answers (1)

Arslan Ali
Arslan Ali

Reputation: 17812

You can uninstall Rails, and re-install it, and reinstalling it will convert the version to the latest.

gem uninstall rails
gem install rails # To re-install it.

Edit:

If you do not want to uninstall Rails, you may need to create a new Gemset for using using Rails 5 throughout your project space. Here's how:

rvm gemset create rails-5.0.0
rvm use [email protected] --default

Kindly replace 2.2.2 with the Ruby version that you would like to use, but it should be later than 2.2.2.

Upvotes: 1

Related Questions