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
Fix #previously_new_record?
on destroyed records
#48796
Fix #previously_new_record?
on destroyed records
#48796
Conversation
My take as well.
feels less useful than e.g.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
b0a3aab
to
bce4265
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this for a bit and I'm kind of on the fence - it would depend whether we think a save and delete are different for this context. I think it is since a double save makes previously_new_record?
return false
. I think the docs should be updated though to reflect this change. Also with the slight change in behavior that might be surprising, can you add a CHANGELOG entry too?
Ref: rails#48794 `#previously_new_record?` should return false for records that are created and then destroyed.
bce4265
to
7981988
Compare
Yeah, I was on the fence about this too. I ended up leaning towards these changes because the primary use case around I've updated the docs and added a CHANGELOG entry -- let me know what you think 😄 |
…ly-new-record Fix `#previously_new_record?` on destroyed records
Motivation / Background
Ref: #48794
cc @eizengan
Based on the documentation for
#previously_new_record?
:IMO a record that was previously created and has since been destroyed and removed from the database should no longer be considered "just created", although one could argue that a
DELETE
is different from a "save".Detail
Set
@previously_new_record
tofalse
in#destroy
and#delete
methods.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]