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
has_one association getting deleted on using create_association & validation fails #46737
Comments
4 tasks
s-mustafa
added a commit
to s-mustafa/rails
that referenced
this issue
Dec 15, 2022
Hey @s-mustafa, your test is passing on the main branch. Now we remove the old association before creating a new one, so in your case the exception will never be raised. Probably fixed by #46386, #46790
|
@byroot I think it can be closed. |
Actually, we might need to backport to 7.0-stable. |
Backported in 83009f9 |
This was referenced Jul 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
Expected behavior
The existing has_one relation from the database should not get deleted. The transaction should be rolled back.
Actual behavior
System configuration
Rails version:
7.0.4
Ruby version:
3.1.2
More info
Tried debugging this and seems the associated record is getting deleted because of
dependent: :destroy
onUser
model. This method is being called which deletes this associated record. It seems intentional deletion but I am not sure if it should be the expected behavior in this case. Let me know if I am missing any context here.The text was updated successfully, but these errors were encountered: