Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression 4.1.6.rc1] second association added to a new record does not get updated #16620

Closed
seanwalbran opened this issue Aug 21, 2014 · 2 comments
Milestone

Comments

@seanwalbran
Copy link

In activerecord 4.1.6.rc1, in a transaction where two associations have items added to an object which is a new record, the second association's object does not get updated.

This appears to be due to this commit: c6a8e09 , which sets @new_record_before_save to false after the first association's object gets updated.

Standalone repro gist here: https://gist.github.com/seanwalbran/b6f8eb882474d32e0a3d
/cc @rafaelfranca

@rafaelfranca rafaelfranca added this to the 4.1.6 milestone Aug 22, 2014
@rafaelfranca
Copy link
Member

Thanks

rafaelfranca added a commit that referenced this issue Sep 5, 2014
Callback order in Active Record objects are important. Users should not
define callbacks before the association definition or surprising
behaviours like the described at #3798 will happen. This callback order
dependency is documented at https://github.com/rails/rails/blob/31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1/activerecord/lib/active_record/associations.rb#L1222-1227.

This reverts #15728.

Fixes #16620.

Conflicts:
	activerecord/test/cases/associations/has_many_associations_test.rb
rafaelfranca added a commit that referenced this issue Sep 5, 2014
Callback order in Active Record objects are important. Users should not
define callbacks before the association definition or surprising
behaviours like the described at #3798 will happen. This callback order
dependency is documented at https://github.com/rails/rails/blob/31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1/activerecord/lib/active_record/associations.rb#L1222-1227.

This reverts #15728.

Fixes #16620.

Conflicts:
	activerecord/test/cases/associations/has_many_associations_test.rb
@seanwalbran
Copy link
Author

Looks great -- thanks, @rafaelfranca!

rafaelfranca added a commit that referenced this issue Sep 8, 2014
Callback order in Active Record objects are important. Users should not
define callbacks before the association definition or surprising
behaviours like the described at #3798 will happen. This callback order
dependency is documented at https://github.com/rails/rails/blob/31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1/activerecord/lib/active_record/associations.rb#L1222-1227.

This reverts #15728.

Fixes #16620.

Conflicts:
	activerecord/lib/active_record/autosave_association.rb
	activerecord/test/cases/associations/has_many_associations_test.rb
rafaelfranca added a commit that referenced this issue Sep 8, 2014
Callback order in Active Record objects are important. Users should not
define callbacks before the association definition or surprising
behaviours like the described at #3798 will happen. This callback order
dependency is documented at https://github.com/rails/rails/blob/31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1/activerecord/lib/active_record/associations.rb#L1222-1227.

This reverts #15728.

Fixes #16620.

Conflicts:
	activerecord/lib/active_record/autosave_association.rb
	activerecord/test/cases/associations/has_many_associations_test.rb
trungpham pushed a commit to trungpham/rails that referenced this issue Sep 18, 2014
Callback order in Active Record objects are important. Users should not
define callbacks before the association definition or surprising
behaviours like the described at rails#3798 will happen. This callback order
dependency is documented at https://github.com/rails/rails/blob/31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1/activerecord/lib/active_record/associations.rb#L1222-1227.

This reverts rails#15728.

Fixes rails#16620.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants