Skip to content

Commit c52dc7b

Browse files
committed
Don't check #present? of ActiveRecord objects because it's always true
(or the variable is assigned nil and it's always false) While the rails maintainers argue about whether it's a good idea rails/rails#35059 I found this because out of curiosity I ran our test suite with ApplicationRecord#present? raising in our projects
1 parent 9babda8 commit c52dc7b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: lib/closure_tree/hierarchy_maintenance.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _ct_validate
2323
if !(defined? @_ct_skip_cycle_detection) &&
2424
!new_record? && # don't validate for cycles if we're a new record
2525
changes[_ct.parent_column_name] && # don't validate for cycles if we didn't change our parent
26-
parent.present? && # don't validate if we're root
26+
parent && # don't validate if we're root
2727
parent.self_and_ancestors.include?(self) # < this is expensive :\
2828
errors.add(_ct.parent_column_sym, I18n.t('closure_tree.loop_error', default: 'You cannot add an ancestor as a descendant'))
2929
end

0 commit comments

Comments
 (0)