On Dec 3, 9:17 pm, "Dan Kubb (dkubb)" <[EMAIL PROTECTED]> wrote:
> Hi Mark,
>
> > >   role.user = User.new(attributes)
> > >   role.user.save  # or just role.save
>
> > > Which also seems clumsy.  
>
> > Isn't this consistent with Dirkjan's comment here -
>
> In the above example the user is a child of the Role instance.  When
> the role is saved it would also save all the children, which is
> consistent with every other parent/child relationship in DM.
>
> When I said clumsy, I meant that not allowing a way to initialize and
> create a child in one method call from the role is clumsy.  The above
> code should actually still work, it's just the long way of doing it..
> much the same as the long form for creating a child within a one to
> many association can be written like so:
>
>   # NOTE: this is not idiomatic DataMapper code
>   child = parent.children.build(attributes)
>   parent.children.save  # or just child.save or parent.save
> (preferred)
>
> I just think it's reasonable to have a comparable method to
> parent.children.create, but for creating children of one to one
> associations.
>
> Dan
> (dkubb)

Ok thanks. I had keyed on to your comments on your first example and
the issue when role isn't initially saved. If role is already saved, I
understand your point.

Mark.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to