-
Notifications
You must be signed in to change notification settings - Fork 3
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
Rails 5.2 Fixing has one callbacks #3
Conversation
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.
the approach seems okay considering the behaviour introduced by active record 5.2, I just have minor comments
case options[:dependent] | ||
when :destroy | ||
target.destroy | ||
if target.respond_to?(:soft_destroyed?) |
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.
does permanent_records
define soft_destroyed
?
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.
No, I believe it is our concern that defines this method. But as permanent_records is basically unmaintained I thought it best to cover more possibilities in case our implementation becomes the actual way we do this.
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.
it is good to cover it in our case, but in the context of this gem, it is not provided, so thanks for removing it
when :destroy | ||
target.destroyed_by_association = reflection | ||
target.destroy | ||
if target.respond_to?(:soft_destroyed?) |
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.
same as above
target.destroy | ||
if target.respond_to?(:soft_destroyed?) | ||
raise ActiveRecord::Rollback unless target.soft_destroyed? | ||
elsif target.respond_to?(:destroyed?) |
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.
also, seems like we only need to target deleted?
since permanent_records
handle the deleted as
def deleted?
if is_permanent?
!!deleted_at # rubocop:disable Style/DoubleNegation
else
destroyed?
end
end
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.
the deleted?
method gets added to all AR models 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.
I assume so
@danieltheodosius I've updated to remove the extraneous method checks |
No description provided.