> From: Thomas Townsend <tlt@vwg.com>
> Subject: [Rails] adding a child record
> Here''s a super-newbie question.... How do I go about adding
> child records?
>
> I have a table called ''accounts'' to which I want to add
> invoices (an account can have many invoices). I have the two
> models (accounts and
> invoices) all set up.
>
> On the account web page, I have a button_to link to an action
> called ''add_invoice''. I added a def for
''add_invoice'' in
> account.rb, but I can''t figure out what to put inside the
> def. Is another controller needed (invoice.rb)? Can I do it
> from within account.rb?
>
> I''m trying to wrap my head around this concept - can anyone help?
Imo, the decision is to be made on the requirements. If this is the only
place that you need to add invoices from, then just use this controller
and do a create method on the invoice model.
Regards,
Bharat