views:

51

answers:

3

I am actually reading a rails book that is written for rails 2.3.5. I want to test Rails 3 beta as well. Is it possible to have such a setup in my Mac OS leopard?

I have tried with gem list -d rails. There are many versions stored in my mac but I don't know how to use different versions of rails while creating applications using rails command

+2  A: 

The way to do this anymore is to use RVM, the Ruby Version Manager, which isolates different Ruby environments from each other.

A coworker of mine did a blog entry on setting up Rails 3 and RVM (and Ruby 1.9), which you might find interesting.

RyanWilcox
+2  A: 

Yes! Try rvm. It is awesome, you can have many different versions of Ruby, and for each one you can have different versions of gems. And you can run the same tests on all those versions. Isn't that cool?!

Quick How-To:

$ rvm install ruby-1.8.7 --default
$ gem install rails -v 1.0.0
$ rvm gemset create rails238
$ rvm 1.8.7@rails238
$ gem install rails -v 2.3.8

Now,

$ rvm 1.8.7

will give you ruby 1.8.7 and rails 1.0

And,

$ rvm 1.8.7@rails238

will give you ruby 1.8.7 and rails 2.3.8

You can make 2.3.8 as default one with

$ rvm use 1.8.7@rails238 --default

BTW rvm is documented really good.

vava
I need to have Rails 1.0 and Rails 2.3.8 (the latest stable version) in my mac. And I have to use 1.0 for some projects and 2.3.8 for others... Can i Do it without installing a huge separate stack of ruby environment ?
lakshmanan
+1  A: 

While RVM is great there's no need for it in this use-case.

Install the Rails 3 gem: gem install rails—pre

Create new project: rails project_name (this will use the latest version installed)

To create projects with a specific version: rails 2.3.5 project_name

Tom
wow, thats what I was looking for... btw, what is rails--pre
lakshmanan
rails--pre is the pre-release version of Rails 3.
Tom
Do note that that it's actually "rails _ 2.3.5 _ project_name" (without the spaces between the version number and the underscores). StackOverflow formatted the original.
Tom