lib/closure_tree/finders.rb in closure_tree-6.0.0.alpha vs lib/closure_tree/finders.rb in closure_tree-6.0.0.gamma
- old
+ new
@@ -50,15 +50,10 @@
scope.without(self)
end
module ClassMethods
- # Fix deprecation warning:
- def _ct_all
- (ActiveRecord::VERSION::MAJOR >= 4) ? all : scoped
- end
-
def without(instance)
if instance.new_record?
all
else
where(["#{_ct.quoted_table_name}.#{_ct.quoted_id_column_name} != ?", instance.id])
@@ -86,10 +81,10 @@
_ct.scope_with_order(s.readonly(false))
end
def with_ancestor(*ancestors)
ancestor_ids = ancestors.map { |ea| ea.is_a?(ActiveRecord::Base) ? ea._ct_id : ea }
- scope = ancestor_ids.blank? ? _ct_all : joins(:ancestor_hierarchies).
+ 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