Forum: Ruby on Rails Interactive generator

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
59610f5c82493698d8313222ea71bfc1?d=identicon&s=25 Bernd Burnt (burnt)
on 2007-06-05 11:00
Hi,
I am currently writing a rails generator. However it will be a little
bit more complex than the standard generators (e.g. model). Therefore I
do not want, that the user has to give all arguments as parameters to
the generator script.
I thought about an interactive generator, that asks the user to enter
different parameters and reads them with "gets".
When I have a "gets" in the manifest method of my generator, it raises
an error "no such file or directory - <args[0]>
Does anyone have an idea how I can read user input in a generator
script?
59610f5c82493698d8313222ea71bfc1?d=identicon&s=25 Bernd Burnt (burnt)
on 2007-06-05 15:30
Hi all,
I could solve the problem myself. For whomever it might be useful, the
problem was that "gets" tried to read a file named after the first input
parameter to the generator script. Therefore $stdin.gets must be used.

Cheers
Bernd

Bernd Burnt wrote:
> Hi,
> I am currently writing a rails generator. However it will be a little
> bit more complex than the standard generators (e.g. model). Therefore I
> do not want, that the user has to give all arguments as parameters to
> the generator script.
> I thought about an interactive generator, that asks the user to enter
> different parameters and reads them with "gets".
> When I have a "gets" in the manifest method of my generator, it raises
> an error "no such file or directory - <args[0]>
> Does anyone have an idea how I can read user input in a generator
> script?
This topic is locked and can not be replied to.