Tutorial for writing generators?

Hi, I just completed the first version of an application. I now find that subsequent version require me to do pretty much the same thing all over again but for different types of things.

For example, I need to: 1. Create a new model (say foo) and a set of related migrations 2. Add a bunch of 'belongs_to' statements to the new model 3. Add 'has_many foo' to a couple of other models 4. Create a controller and a set of views for displaying the data in foo (like scaffold) 5. Add a before_filter to this controller 6. Create a link to the index page of this controller in my main layout 7. Modify the create method in this controller to create the links between the foreign keys 8. Create a POST string to pass data to this controller (to be used by another program) 9. ...and so on.

Normally, I would write that list up and go about doing it a step at a time. However, when it comes to Rails, I feel lazy :-S It seems that the DRY way is to use a generator. Is there a good tutorial that I could follow?

Thanks, Mohit.

Hi Mohit,

These were useful for me:

http://wiki.rubyonrails.org/rails/pages/UnderstandingGenerators http://www.aidanf.net/rails/creating-your-own-generators-in-rails

Also you might find it useful to look up Rails::Generator and its related classes at:

-- Urbanus http://goldberg.240gl.org

urbanus wrote:

Hi Mohit,

These were useful for me:

http://wiki.rubyonrails.org/rails/pages/UnderstandingGenerators http://www.aidanf.net/rails/creating-your-own-generators-in-rails

Also you might find it useful to look up Rails::Generator and its related classes at:

http://railsmanual.com/list/classes

-- Urbanus http://goldberg.240gl.org    Thanks Urbanus! I shall take a look at these resources :slight_smile: Cheers Mohit.