# Modifiying existing files in your template script

**URL:** <https://www.ruby-forum.com/t/modifiying-existing-files-in-your-template-script/189495>\
**Category:** Rails\
**Created:** [June 1, 2010, 7:43pm UTC](https://www.ruby-forum.com/t/modifiying-existing-files-in-your-template-script/189495 "2010-06-01T19:43:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bb73d2/32.png) [@robo](https://www.ruby-forum.com/u/robo)\
**Post date:** [June 1, 2010, 7:43pm UTC](https://www.ruby-forum.com/t/modifiying-existing-files-in-your-template-script/189495/1 "2010-06-01T19:43:51Z")

</div>

Ok, so I just started digging into template files using the command

rails mynewprojectname -m templatescript.rb

and it’s really, really awesome 8)

What I want to do is something like this in my script -

generate(:scaffold, “user name:string”)  
rake(“db:migrate”)

# add some code into the scaffold generate model and controller here!

Essentially, I would like my template script to populate my scaffold  
generated files with some default code so I don’t have to type the  
same things over and over again. Make sense? As an example, by the  
time my template is done, it’d be nice to have a bunch of models up  
and running with all their associations set up.

From what I’ve read about templates, it seems like this should be  
feasible, but all i’ve seen so far is some template snippets for  
extending ruby’s object class to add some methods like not\_nil?, which  
is great, but not quite what I’m looking for 🙂

Thanks for taking the time to look at this!
