From 777fa257aaa962bf67f6e5522efaa420ea7dc88b Mon Sep 17 00:00:00 2001 From: Kevin Deisz Date: Fri, 29 May 2015 09:41:03 -0400 Subject: Allow Enumerable#pluck to take a splat. This allows easier integration with ActiveRecord, such that AR#pluck will now use Enumerable#pluck if the relation is loaded, without needing to hit the database. --- activerecord/lib/active_record/relation/calculations.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 402b317d9c..7a28a98721 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -161,6 +161,10 @@ module ActiveRecord end end + if loaded? && (column_names - @klass.column_names).empty? + return @records.pluck(*column_names) + end + if has_include?(column_names.first) construct_relation_for_association_calculations.pluck(*column_names) else -- cgit v1.2.3