Skip to content

Commit

Permalink
Fix warnings in Rails 5.1 about using dirty tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Aug 30, 2017
1 parent 3b042ad commit 5baf72a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ancestry/instance_methods.rb
Expand Up @@ -78,7 +78,13 @@ def child_ancestry
# New records cannot have children
raise Ancestry::AncestryException.new('No child ancestry for new record. Save record before performing tree operations.') if new_record?

if self.send("#{self.ancestry_base_class.ancestry_column}_was").blank? then id.to_s else "#{self.send "#{self.ancestry_base_class.ancestry_column}_was"}/#{id}" end
if ActiveRecord::VERSION::STRING >= '5.1.0'
ancestry_column_was = self.attribute_in_database(self.ancestry_base_class.ancestry_column)
else
ancestry_column_was = self.send("#{self.ancestry_base_class.ancestry_column}_was")
end

ancestry_column_was.blank? ? id.to_s : "#{ancestry_column_was}/#{id}"
end

# Ancestors
Expand Down

0 comments on commit 5baf72a

Please sign in to comment.