From 5ded81ee72127917cc94d06d168f830a0097adde Mon Sep 17 00:00:00 2001 From: Chris Sturgill <chris@thesturgills.com> Date: Wed, 24 Oct 2012 16:02:57 -0400 Subject: [PATCH 1/2] Use :pluck and avoid AR overhead --- lib/closure_tree/acts_as_tree.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/closure_tree/acts_as_tree.rb b/lib/closure_tree/acts_as_tree.rb index ca6efe8a..14a2af26 100644 --- a/lib/closure_tree/acts_as_tree.rb +++ b/lib/closure_tree/acts_as_tree.rb @@ -352,7 +352,7 @@ def without_self(scope) end def ids_from(scope) - scope.select(:id).collect(&:id) + scope.uniq.pluck(:id) end From 490a91adb03e9dfa20ad5a9c591577963c08cdca Mon Sep 17 00:00:00 2001 From: Chris Sturgill <chris@thesturgills.com> Date: Wed, 24 Oct 2012 16:45:41 -0400 Subject: [PATCH 2/2] Try pluck, fallback to select and collect --- lib/closure_tree/acts_as_tree.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/closure_tree/acts_as_tree.rb b/lib/closure_tree/acts_as_tree.rb index 14a2af26..a86dd14c 100644 --- a/lib/closure_tree/acts_as_tree.rb +++ b/lib/closure_tree/acts_as_tree.rb @@ -352,7 +352,7 @@ def without_self(scope) end def ids_from(scope) - scope.uniq.pluck(:id) + scope.try(:pluck, :id) || scope.select(:id).collect(&:id) end