View Full Version : Save a new object and its associations together

29 Mar 2012, 2:29 AM
Hi all,

I have a User model and a Post model. They have a one-many relationship. So now, I would like to save a new User object and all of its Posts to the server. Please tell me how to do that. Thank so much!


29 Mar 2012, 7:44 AM
When you save a model, it's associated data is not part of the model so it's not sent.

29 Mar 2012, 8:23 AM
Yap.. unfortunately... You can get the associated data with getAssociatedData and set that to the model instance aka record you want to save.

11 Apr 2012, 9:02 AM
If I can load nested Model data (through associations) in one shot, why can't I persist it that way?