2006/4/13, John Siracusa <[EMAIL PROTECTED]>:
[...]
> > Also I understood that my approach isn't very effective so I'll use
> > the many-to-one relation of Product object in order to add one more
> > product for given vendor:
> >    my $product = Product->new;
> >    $product->vendor($vendor); # $vendor ISA 'Vendor'
> >    $product->save();
>
> If you just want to add to a one-to-many related list, you should use
> the "add_on_save" method.  Continuing to use the tutorial example, it
> will be named add_products():
>
>    $vendor->add_products(Product->new);
>    $vendor->save();
>
> That will just add the new product, rather than deleting them all and
> then re-saving the entire list.

Aaaha! I wasn't aware of add_something(). Nice! I really prefer this
approach ($vendor->add_products instead of $product->vendor) - it
seems more natural to me.

Thanks a lot, John! Keep up the good work!

-- Svi

Reply via email to