7

I know that this error has been discussed elsewhere on the web, and this may seem like a stupid question, but I've got a very strange situation on my hands here.

I'm running on Snow Leopard, with fully updated Ruby and Rails gems. I created a new Rails project using ruby new testing, then navigated into that folder using cd ~/testing, and tried to create a basic scaffolding using ruby script/generate scaffold newtest name:string, and I got this error back:

ruby: No such file or directory -- script/generate (LoadError)

I have searched Google thoroughly and tried to implement every solution that I could, but nothing has been working. I don't understand why I have this error or how to fix it.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Jenius
  • 73
  • 1
  • 1
  • 3

3 Answers3

14

If you are on rails 3 then the command is:

rails generate scaffold newtest name:string

Or the slightly shorter:

rails g scaffold newtest name:string

Notice rails not ruby.

Gazler
  • 83,029
  • 18
  • 279
  • 245
2

If you're on Rails 3, you need to use the rails command instead, which now does much of the scripting.

(This is according to another StackOverflow question.)

Community
  • 1
  • 1
Platinum Azure
  • 45,269
  • 12
  • 110
  • 134
  • Great call. I feel like an idiot. The correct total command is: rails generate scaffold [NAME] [FIELDS] – Jenius Feb 08 '11 at 00:19
  • Don't worry about it. I'm still on Rails 2 myself, so I know I'm going to be in for a bumpy ride if I ever try Rails 3. (That said, currently I'm trying Django. *apologetic smile*) – Platinum Azure Feb 08 '11 at 02:33
1

If you're using the latest version of rails then you no longer use script/generate.

In Rails 3 try using something like this instead:

cd ~/testing
rails generate scaffold Post name:string title:string content:text

You can find more info on the difference between rails 2 and rails 3 here if you like:

http://www.viget.com/extend/rails-3-generators-scaffolding/

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
2potatocakes
  • 2,240
  • 15
  • 20