On Aug 5, 1:17 pm, Ashley Moran <[email protected]> wrote:
> On 27 Jul 2009, at 20:47, Jorge wrote:
>
> > child.parent.someattribute = value => value
> > child.parent.save => true
>
> > The problem is, when I call child.parent.reload, the old value is
> > still in someattribute.  It seems like at the very least, save should
> > return false when the change doesn't make it to the database.
>
> > Here's a pastie with a simple example:http://pastie.org/560681
>
> > I'm using dm-core 0.9.11
>
> > Is this a bug, or am I misunderstanding how belongs_to associations
> > should be used?

I have the same problem on dm-core 0.9.11.  I am not sure of the cause
since I am pretty new to datamapper, but I have a parent child
relationship where the child wants to change an attribute on the
parent and save the parent.  Are associations attributes immutable by
default?

My workaround is
parent = Object.get(child.parent_id)
parent.attribute = 'blah'
parent.save

That seems to work, but no syntactic sugar.  The bug Ashley mentions
(#960) appears to be dealing with multiple repos, but I can reproduce
just connecting to a single mysql db.

-Curtis

--
Curtis Spencer
Blog: sevenforge.com

--~--~---------~--~----~------------~-------~--~----~
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