开发者

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.


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


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.


Have a look at RVM (Ruby Version Manager)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜