# Customizing generators - extend rails generators vs copy the

**URL:** <https://www.ruby-forum.com/t/customizing-generators-extend-rails-generators-vs-copy-the/70720>\
**Category:** Rails\
**Created:** [October 2, 2006, 12:10pm UTC](https://www.ruby-forum.com/t/customizing-generators-extend-rails-generators-vs-copy-the/70720 "2006-10-02T12:10:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 2, 2006, 12:10pm UTC](https://www.ruby-forum.com/t/customizing-generators-extend-rails-generators-vs-copy-the/70720/1 "2006-10-02T12:10:32Z")

</div>

Hi,

I’ve got some generator tweaks I’d like to make (e.g. controllers, model  
&  
scaffold) but I’m wondering whether I should either (a) take a copy and  
modify the existing controllers or (b) try to extend the existing  
generators  
so as to better leverage rails upgrades in the future.

Does anyone know whether (b) is possible? That is, is there a way to  
make  
changes/additions to the custom rails generators in a way that won’t  
break  
for future rails releases? Or is this difficult or not possible and I  
should really just create my own generators (based on the rails ones as  
a  
starting point).

Tks  
Greg

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 2, 2006, 3:22pm UTC](https://www.ruby-forum.com/t/customizing-generators-extend-rails-generators-vs-copy-the/70720/2 "2006-10-02T15:22:55Z")

</div>

Greg H. \<greg.hauptmann.ruby@…\> writes:

> Hi,I’ve got some generator tweaks I’d like to make (e.g. controllers, model &  
> scaffold) but I’m wondering whether I should either (a) take a copy and  
> modify  
> the existing controllers or (b) try to extend the existing generators so  
> as to  
> better leverage rails upgrades in the future.  
> Does anyone know whether (b) is possible? That is, is there a way to make  
> changes/additions to the custom rails generators in a way that won’t  
> break for  
> future rails releases? Or is this difficult or not possible and I  
> should really  
> just create my own generators (based on the rails ones as a starting  
> point).

Personally I’d go with taking a copy, otherwise there’s no way to tell  
whether  
the changes being made are going to have aneffect on the lines you’re  
adding.

On the other hand, it’s definitely possible to call a generate script  
from your  
generate script, using m.dependency in your generate script, for example

m.dependency ‘model’, [@model\_name] # adds or removes a model depending  
on  
# whether this script is being called with create or destroy

Gareth
