Skip to content

Commit

Permalink
change the valid to not only check the entire object
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed May 20, 2021
1 parent 0a1337e commit 824e8e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ancestry/materialized_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module InstanceMethods
# Validates the ancestry, but can also be applied if validation is bypassed to determine if children should be affected
def sane_ancestry?
ancestry_value = read_attribute(self.ancestry_base_class.ancestry_column)
(ancestry_value.nil? || !ancestor_ids.include?(self.id)) && valid?
ancestry_value.nil? || (!ancestor_ids.include?(self.id) && (valid? || errors[self.ancestry_base_class.ancestry_column].blank?))
end

# optimization - better to go directly to column and avoid parsing
Expand Down

0 comments on commit 824e8e6

Please sign in to comment.