Ruby error: "There is no such file or directory - script / generate (LoadError)"

I know that this error was discussed elsewhere on the Internet, and this may seem like a silly question, but I have a very strange situation here.

I am running on Snow Leopard, with completely updated Ruby and Rails stones. I created a new Rails project using ruby new testing , then moved to this folder using cd ~/testing and tried to create the base scaffold using ruby script/generate scaffold newtest name:string , and I got this error:

ruby: There is no such file or directory - script / generate (LoadError)

I carefully searched Google and tried to implement all possible solutions, but nothing worked. I don’t understand why I have this error or how to fix it.

+7
source share
3 answers

If you are on rails 3, then the command:

 rails generate scaffold newtest name:string 

Or a little shorter:

 rails g scaffold newtest name:string 

Pay attention to the rails not ruby.

+13
source

If you use Rails 3, you need to use the rails command, which now runs most of the scripts.

(This is consistent with https://stackoverflow.com/a/3142020/... )

+2
source

If you are using the latest version of rails, you are no longer using script / generate.

In Rails 3, try using something like this:

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

More information on the difference between rails 2 and rails 3 can be found here:

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

+1
source

All Articles