Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I switch to older versions of the ruby/rails environment?

I'm trying to keep along with the Tekpub Build your own blog on rails screencast. I'm still very much a ruby novice and the problem is that I have Rails 3 installed while Rob uses an older version (Of the top of my head: version 2.3.2).

I know how to get that version of rails with gem install rails --version=2.3.2 but when I type rails new the version of the application is rails 3. How do I make this particular app work with the older version? I know this has something to do with rvm but I have no idea how to do anything but the basic rvm use operation.

like image 437
George Mauer Avatar asked Nov 14 '10 20:11

George Mauer


3 Answers

Try,

rvm use <ruby version>
rvm gemset create rails2.3.2
rvm <ruby version>@rails2.3.2
gem install rails --version=2.3.2

Finally the syntax to create a new rails app in older versions of rails was just:

rails <appanme>

For more information about gemsets: RVM: Named Gem Sets

like image 145
Jakobinsky Avatar answered Sep 18 '22 16:09

Jakobinsky


This will install Ruby 1.8.7 and then create a gemset that will contain only a specific set of gems:

rvm install 1.8.7
rvm --create use 1.8.7@old_rails
gem install rails --version=2.3.2

Whenever you want to use this after the first time just:

rvm use 1.8.7@old_rails

.rvmrc files are really useful for automatically managing different sets of Ruby versions and gems. If you create file called .rvmrc in the project directory and put this line in it:

rvm --create use 1.8.7@old_rails

Then every time you cd into that directory RVM will switch to Ruby 1.8.7 and the gemset "old_rails". Have a look at the docs for .rvmrc here: http://rvm.beginrescueend.com/workflow/rvmrc/

Of course you can change "1.8.7" for "1.8.6", "1.8.7-p249", "ree-1.8.7-2010.02" or any other Ruby version you like, I just assumed that you would want 1.8.7.

like image 24
Theo Avatar answered Sep 19 '22 16:09

Theo


Have a look at RVM (Ruby Version Manager)

like image 34
Charlie Martin Avatar answered Sep 20 '22 16:09

Charlie Martin