Creating a Controller

Hi,
I’m new to ruby on rails, but let me let you know, I’m very excited
about learning it. Anyway, I’m trying to create a controller through
the console but something makes it not work. I am running windows
vista and using Instant Rails. Firstly I open up a ruby console
window, and go to the directory of my app, named training. As soon as
I get there I type script/generate and it says ‘script’ is not
recognized as an internal or external command… I also tried script/
generate say (that will be the name of the controller). That gives the
same output. I’ve also tried:
script/generate controller
script/generate controller say
./script/generate controller say
/script/generate controller say
etc.
I checked and I have the folder script, with generate inside. I’m been
trying to figure this out for days, so please, any help would be
deeply appreciated. If I am unclear, please say so.

Thanks in advanced for your time and help.

I’m not on windows, but I think you need to do:

ruby script/generate controller say

If you just:
ruby script/generate controller

it will display a brief help of the command and options.

Thanks for the quick reply!
Man I feel like a complete idiot! After looking at only one other post
here I realized I was forgetting to put ruby in front of script.

Thanks again, problem solved though.

On windows you’ve got to say:

ruby script\generate blah blah blah

So-just throw a "ruby " on the front there & you should be good.

BTW, what that’s doing is taking the ruby script called
‘generate’ (note the lack of a file extension–very non-windows-y)
which lives in the ‘script’ subdirectory of your app, and passing it
to the ruby interpreter. On other platforms you just pass the script
file to the OS for execution, and it looks on the “shebang” line (the
one starting with #!) to see what binary executable to use.

Cheers,

-Roy

ruby script/generate controller say

You need ruby at the start of the command or windows will trow a wobly
at you :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs