lib/ancestry/treeview/instance_methods.rb in ancestry-treeview-0.0.1 vs lib/ancestry/treeview/instance_methods.rb in ancestry-treeview-0.0.2

- old
+ new

@@ -1,9 +1,12 @@ module Ancestry module InstanceMethods def tree(params = {}) return '' unless self subtree = (params[:to_depth].present? ? self.subtree(to_depth: params[:to_depth]) : self.subtree).order('path ASC') + if params[:conditions].is_a?(Array) || params[:conditions].is_a?(Hash) + subtree = subtree.where(params[:conditions]) + end html = '<div class="ancestry-treeview">' open_ul = 0 prev_depth = self.depth - 1 subtree.each do |node| curr_depth = node.depth