closure_tree
closure_tree copied to clipboard
reason for with_ancestor method using map
# lib/closure_tree/finders.rb
def with_ancestor(*ancestors)
ancestor_ids = ancestors.map { |ea| ea.is_a?(ActiveRecord::Base) ? ea._ct_id : ea }
scope = ancestor_ids.blank? ? all : joins(:ancestor_hierarchies).
where("#{_ct.hierarchy_table_name}.ancestor_id" => ancestor_ids).
where("#{_ct.hierarchy_table_name}.generations > 0").
readonly(false)
_ct.scope_with_order(scope)
end
def with_ancestor(*ancestors)
scope = ancestor_ids.blank? ? all : joins(:ancestor_hierarchies).
where("#{_ct.hierarchy_table_name}.ancestor_id" => ancestor_ids).
where("#{_ct.hierarchy_table_name}.generations > 0").
readonly(false)
_ct.scope_with_order(scope)
end
seem to be the same