Mohit Sindhwani | 26 Aug 09:10
Favicon

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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---

urbanus | 26 Aug 12:31

Re: Tutorial for writing generators?


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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---

Mohit Sindhwani | 26 Aug 19:23
Favicon

Re: Tutorial for writing generators?


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 :) Cheers Mohit. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@... To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---

Gmane