[LRUG] Binding the creation of 2+ objects together

Steve Ganly steve at concept-shop.com
Thu Jul 31 10:01:49 PDT 2008


On Thu, Jul 31, 2008 at 05:42:55PM +0100, Andrew Stewart wrote:
> You could do:
>
> models = [ @a, @b ]
> models.each(&:save) if models.map(&:valid?).all?
>
> Regards,
> Andy Stewart
>

Very nifty Andy. Like it alot.

I didn't realise you were an old Perl hacker :-)




More information about the Chat mailing list