-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Duplicate insert on autosave for specific HABTM-has_one combo #24032
Comments
Also If you change |
Introduced in c7adc61 |
@rafaelfranca I see that this has been added into 5.1 milestone, do you want to go with the existing pr or do you think something different. |
Oh, I thought it was caused by a commit only present in 5.1, but seems this bug is also present in 4.2. I'm removing the milestone and I'll leave the PR review with @sgrif |
There's definitely a regression from 5.0.2 to 5.1.0.beta1. Is @nbekirov's test case is failing on 4.2? If so, I'll try to put together another test case that demonstrates the issue. Basically, what I'm seeing is that when upgrading from 5.0.2 to 5.1.0.beta1, I get |
Yes, it is failing in 4.2 https://gist.github.com/nbekirov/01c34d2b99ed5bcf9154#file-rolif_test-rb-L11. |
Here's the regression, and this is what I was referring to in my comment above about it being introduced in c7adc61:
I do remember reading a bug report about using accepts_nested_attributes for a has_one relationship, but I don't remember the details and could not find it when I looked around just now. |
PR #28596 is ready |
Steps to reproduce
Here is my Active Record Executable Test Case
This issue is related to Rolify: Duplicate Roles #228
Some observations:
has_and_belongs_to_many
andbelongs_to
inUser
there is no issueautosave: false
tohas_and_belongs_to_many
inUser
there is no issueHere is an issue I've found that seems related but I don't think is quite the same: has_and_belongs_to_many autosaves duplicate records
Expected behavior
One
User
with oneOrganisation
and oneRole
savedActual behavior
One
User
with oneOrganisation
and twoRole
-s savedSystem configuration
Rails version:
N/A
Ruby version:
The text was updated successfully, but these errors were encountered: