Mellon
Mellon

Reputation: 38832

create a new model raise error

I am working on a Rails V2.3.2 project, I wanna create a new model, so I run the following command:

rails generate model cars name:string owner:string description:text

But I got the following error:

/home/myname/.rvm/gems/ree-1.8.7-2011.03@myapp/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
    from /home/myname/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:55:in `gem_original_require'
    from /home/myname/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:55:in `require'
    from /home/myname/.rvm/gems/ree-1.8.7-2011.03@myapp/gems/activesupport-2.3.2/lib/active_support.rb:56
...

How to get rid of this error?

P.S.

I have the code:

require 'thread'
require File.join(File.dirname(__FILE__), 'boot')

in my RakeFile , config/engironment.rb and script/server.rb

Upvotes: 0

Views: 325

Answers (2)

rubyprince
rubyprince

Reputation: 17793

In Rails 2, the generate command is:

ruby script/generate model car name:string owner:string description:text

rails generate is the command used in Rails 3

Also, models are singular by convention (use car instead of cars. It will avoid much head-ache afterwards).

Upvotes: 1

bor1s
bor1s

Reputation: 4113

Try to insert this code before boot.rb inside Rakefile, config/environment.rb, script/server:

require 'thread'
require File.join(File.dirname(__FILE__), 'boot')

If you still get the error above you can also add require 'thread' in your boot.rb after the RAILS_ROOT constant was defined:

RAILS_ROOT = "#{File.dirname(FILE)}/.." unless defined?(RAILS_ROOT)
require 'thread'

Also watch this post: Gem 1.5 with Rails 2.3.x

Upvotes: 1

Related Questions