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

Don't save through records twice (4-1-stable) #15729

Merged
merged 1 commit into from
Jun 19, 2014

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Jun 14, 2014

If the through record gets created in an after_create hook that is
defined before the association is defined (therefore after its
after_create hook) get saved twice. This ensures that the through
records are created only once, regardless of the order of the hooks.

Backports the fix for #3798 to 4.1. Slightly more conservative on the callback order since it's a patch version.

If the through record gets created in an after_create hook that is
defined before the association is defined (therefore after its
after_create hook) get saved twice. This ensures that the through
records are created only once, regardless of the order of the hooks.
@rafaelfranca rafaelfranca merged commit c6a8e09 into rails:4-1-stable Jun 19, 2014
rafaelfranca added a commit that referenced this pull request Jun 19, 2014
Don't save through records twice (4-1-stable)

Conflicts:
	activerecord/test/cases/associations/has_many_through_associations_test.rb
@sgrif sgrif deleted the sg-double-save-hm-t-4-1-stable branch June 19, 2014 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants