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
+ ActiveRecord::Base#destroy! #6629
Conversation
# and <tt>destroy!</tt> raises ActiveRecord::RecordNotSaved. See | ||
# ActiveRecord::Callbacks for further details. | ||
def destroy! | ||
destroy or raise ActiveRecord::RecordNotDestroyed |
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.
Can we use ||
? It is in Rails Code Guidelines to not use and
and or
. Thanks!
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.
Sure, done.
BTW, the commit also supplements the rdoc for |
Great, can we have a changelog entry as well please? |
Changelog entry added. |
# | ||
# There's a series of callbacks associated with <tt>destroy!</tt>. If | ||
# the <tt>before_destroy</tt> callback return +false+ the action is cancelled | ||
# and <tt>destroy!</tt> raises ActiveRecord::RecordNotSaved. See |
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.
Ops, just noticed the constant name is wrong here, should be ActiveRecord::RecordNotDestroyed
, right?
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.
Ah, the pitfalls of copy-paste :-)
Fixed, thanks.
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.
Hehe :), thanks.
Add ActiveRecord::Base#destroy!
save!
and variants are super useful when we have some generic exception handler setup, for example withrescue_from
, and we expect the operation to succeed.destroy
actions would benefit the same way of adestroy!
version in the same way (especially since they so often succeed).Doesn't it sound great too? destroy!