# Interactive generator

**URL:** <https://www.ruby-forum.com/t/interactive-generator/105988>\
**Category:** Rails\
**Created:** [June 5, 2007, 11:00am UTC](https://www.ruby-forum.com/t/interactive-generator/105988 "2007-06-05T11:00:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bernd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bernd](https://www.ruby-forum.com/u/bernd)\
**Post date:** [June 5, 2007, 11:00am UTC](https://www.ruby-forum.com/t/interactive-generator/105988/1 "2007-06-05T11:00:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bernd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bernd](https://www.ruby-forum.com/u/bernd)\
**Post date:** [June 5, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/interactive-generator/105988/2 "2007-06-05T15:30:25Z")

</div>

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 B. 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?
