I have an object model where I do jobs for clients, so there is a 1:M
relationship between the Client entity and the Job entity. Assume I
have one existing client and one existing job. Since I have completed
this job, I would like to mark it as closed--or false in my database
vernacular. I also want to rename the client for fun. I am passing the
following, along with the existing Client instance, to Client#update:
{:name => "New Client Name", :jobs=>[{:id=>"4", :open=>"false"}]}
When I do this, I am finding that the job isn't being saved. Here is
the job before the call to Client#update:
#<Job @id=4 @title="Test" @open=true @created_at=Sat, 31 Dec 2011
22:45:32 -0500 @updated_at=Sat, 31 Dec 2011 22:45:32 -0500
@client_id=7>
And here is the job after the call to Client#update:
#<Job @id=4 @title=nil @open=false @created_at=nil @updated_at=nil
@client_id=7>
As you can see, the title is nil (the title wasn't changed and
therefore wasn't passed to update), and the dates usually
automatically populated by DataMapper are nil as well. So it seems
there is an object instance in memory but never persisted.
Immediately after, when ClientsController#show presents the Client
instance to the user, it presents the job in the database--still open
(true).
Any insight into the proper way to update a full object graph at once--
or if it is even possible to do so--is appreciated.
Thanks and Happy New Year.
--
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.