views:

126

answers:

2

Hi,

to clarify: there's only one rails command, which gets installed from the latest Rails gem, which is Rails 3 ATM. However, I'm required to create a Rails 2.3 app.

Running ruby /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/bin/rails fails with a NoMethodError, I suppose because it also tries to use gems from the 3.0.0 release.

Uninstalling the gem produces some strange results:

$ gem uninstall rails-3.0.0  
ERROR:  While executing gem ... (Gem::InstallError)
    cannot uninstall, check `gem list -d rails-3.0.0`

$ gem list -d rails-3.0.0  

*** LOCAL GEMS ***
(and no gems here)

What should I do?

A: 

Install rvm and then create a new gemset, so that Rails 2 is isolated.

Or, go to the directory where you want your Rails 2 app to be, create a Gemfile like a Rails 3 app, but specify gem "rails", "~> 2.3" and run bundle install, and you should now be able to issue rails .

rspeicher
Not `rails .`, but `bundle exec rails .` - bundles aren't picked up by default.
Leonid Shevtsov
+2  A: 

The easiest way to do it was:

  1. Create the directory for the project
  2. Create a Gemfile there containing

    gem "rails", "2.3.9"
    gem "sqlite3-ruby", :require => "sqlite3"
    
  3. Run bundle install

  4. Run bundle exec rails . to create an app in the current path

You don't even need rvm to do this.

Leonid Shevtsov