This project is archived and is in readonly mode.
nestedattributes for has_one and has_many association has different saving sequence
-
José Valim
- Assigned user set to Eloy Duran
Eloy, could you please tell us if this is per design or not? Thanks mate!
-
José Valim
- Assigned user changed from Eloy Duran to José Valim
I talked with Eloy. The current behavior is inherited from previous Rails versions and we could change it. However, we need a valid reason to do that, so what is your use case? And feel free to try out a patch.
-
szetobo
I use Policy as a centralize model to preform all the validation and saving logic to ensure the integrity of the whole policy. Initially I put all related models creation logic under the after_save callback of Policy and trigger it depends on certain event, like status change to certain stage etc. But then I discover that BasicPlan not yet save during after_save invocation of Policy.
Now I have to move some of the logic into PolicyItem and build the association inside Policy's after_save callback. The reason I didn't want to put the logic under PolicyItem is because the related model creation logic is trigger by status change of Policy.
Anyway, I agree that it can be solve without any changes in the Rails framework, although it is not that consistent and doesn't follow principle of least surprise.
I'd very much like to contribute back but due to my experience on ruby and rails, I'm a bit loss after browsing through the source code. I will keep on trying that. Any good hacking guide or reference on rails framework would be helpful for newbie as me. Thanks anyway for the prompt response.
-
José Valim
Hey mate. Any news? Can I help somehow?
-
Santiago Pastorino
- State changed from new to open
- Importance changed from to Low
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale