diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-13 19:58:26 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-13 19:58:26 -0200 |
commit | 724020278480855bddfe749c91f1074d4f50f3c6 (patch) | |
tree | 0e77d63fe11224a6984565b8810299f6a4e09493 /activerecord/lib/active_record/relation/calculations.rb | |
parent | e4e2bcce75b85fb8c1c49509a17bd5dfe6034c32 (diff) | |
parent | d3006f3503cd62510f669fcac84f8dc47c3b333c (diff) | |
download | rails-724020278480855bddfe749c91f1074d4f50f3c6.tar.gz rails-724020278480855bddfe749c91f1074d4f50f3c6.tar.bz2 rails-724020278480855bddfe749c91f1074d4f50f3c6.zip |
Merge pull request #8209 from senny/backport_8176
backport #8176, `#pluck` can be used on a relation with `select` clause.
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 802059db21..8b605dd4f1 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -178,7 +178,9 @@ module ActiveRecord # def pluck(column_name) column_name = column_name.to_s - klass.connection.select_all(select(column_name).arel).map! do |attributes| + relation = clone + relation.select_values = [column_name] + klass.connection.select_all(relation.arel).map! do |attributes| klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes)) end end |