lib/customize/inherited.rb in customize-0.0.1 vs lib/customize/inherited.rb in customize-0.0.2
- old
+ new
@@ -27,15 +27,16 @@
inherit_node.right = right + 1
inherit_node.save
end
def ascent_ids
- @ascent_ids ||=
- InheritNode.where("left < :left and right > :right and node_type = :type",
- :left=>inherit_node.left, :right=>inherit_node.right, :type=>self.class.name).pluck(:node_id)
+ return [] if self.new_record?
+ r = InheritNode.where("left < :left and right > :right and node_type = :type",:left=>inherit_node.left, :right=>inherit_node.right, :type=>self.class.name)
+ r.pluck(:node_id)
end
def descent_ids
+ return [] if self.new_record?
r = InheritNode.where("left > :left and right < :right and node_type = :type",
:left=>inherit_node.left, :right=>inherit_node.right, :type=>self.class.name)
r.pluck(:node_id)
end