This project is archived and is in readonly mode.
accepts_nested_attributes, validates_presence_of - saves associated model
-
Eloy Duran
- Milestone set to 2.3.6
- Assigned user set to Eloy Duran
-
Eloy Duran
- Assigned user changed from Eloy Duran to José Valim
- Importance changed from to
-
Subba
I found the fix for this
below is the reason why children save if parent saves(even when they are not changed)
activerecord/lib/active_record/autosave_association.rb at line 375saved = association.save(:validate => !autosave) if association.new_record? || autosavei am providing patch for this.
this is currently happening in rails3 and rails23stable.
so i am providing two different patches. -
Repository
- State changed from new to resolved
(from [4a0d7c1a439c6ad8d35bf514761824e51fa07df2]) save on parent should not cascade to child unless child changed [#3353 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/4a0d7c1a439c6ad8d35bf514761824... -
José Valim
- State changed from resolved to open
Patch no longer applied for 2-3-stable. Could you please rebase? Thanks!
-
Subba
Jose due to the above patch me below case is not working.
changes to grand children no longer works if parent is not changed.
as saving children is one of the callback.
would you rollback above patch.
is there anyway to detect changes to children@ship = Ship.create(:name => 'Nights Dirty Lightning') @pirate = @ship.create_pirate(:catchphrase => "Don' botharrr talkin' like one, savvy?") @parrot = @pirate.parrots.create!(:name => 'Posideons Killer') @parrot.name = "NewName" @ship.save assert_equal 'NewName', @parrot.reload.name -
José Valim
Do you want me to revert the patch?
-
Subba
yes.
-
Repository
(from [01add55d6a6a67fb487afa040998575111511b6d]) Revert "save on parent should not cascade to child unless child changed [#3353 state:open]"
Please check Lighthouse for more information.
This reverts commit 4a0d7c1a439c6ad8d35bf514761824e51fa07df2.
http://github.com/rails/rails/commit/01add55d6a6a67fb487afa04099857... -
Repository
- State changed from open to committed
(from [658bb4fa25db0b3f61bfb64028274f2365cad506]) Only call save on belongs_to associations if the record has changed or any nested associations have changed (resolves #3353)
Signed-off-by: José Valim jose.valim@gmail.com
https://github.com/rails/rails/commit/658bb4fa25db0b3f61bfb64028274... -
Repository
(from [bda16eb0920780509467bcf051d1a01639357903]) Only call save on belongs_to associations if the record has changed or any nested associations have changed (resolves #3353)
Signed-off-by: José Valim jose.valim@gmail.com
https://github.com/rails/rails/commit/bda16eb0920780509467bcf051d1a...
