aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/calculations.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-09 13:50:08 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-09 13:50:08 -0800
commite0cba3a0fab28f96dc9b5d3a714886583873a7d3 (patch)
tree8712fd8f0b53b7916ae8549decb86928302f00dc /activerecord/lib/active_record/relation/calculations.rb
parent6c50c07d8dbb0b014e68608fe72f807cbe7f5c45 (diff)
parente6c98b83cbf4eab8944601754cc8d0e627b55d6f (diff)
downloadrails-e0cba3a0fab28f96dc9b5d3a714886583873a7d3.tar.gz
rails-e0cba3a0fab28f96dc9b5d3a714886583873a7d3.tar.bz2
rails-e0cba3a0fab28f96dc9b5d3a714886583873a7d3.zip
Merge branch 'master' into instance_reader
* master: (30 commits) Bump tzinfo. 0.3.31 was released on November 6, 2011. Fix GH #4909. Dependency on TZInfo move from AR to AS. moving ordered hash to normal hash because ruby 1.9.3 hash defaultly ordered one Refactored the OrderedHash related stuff Replaced OrderedHash usage with Ruby 1.9 Hash Replaced OrderedHash with Hash for ruby 1.9 series removed unnecessary code replacing the orderhash with hash for ruby-1.9 Clean up some wording. Fix typo. test title changed corresponding to the test replaced active support ordered hash to ruby hash on active resource PostgreSQL does not work in the same way of the other adapters AR::Relation#pluck: improve to work with joins Fix match docs Fix attribute_before_type_cast for serialized attributes. Fixes #4837. Fix failing request test Fixes in AMo README Update README to mention lint. Trim down Active Model API by removing valid? and errors.full_messages ...
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 6bf3050af9..50239f7cb2 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -177,6 +177,9 @@ module ActiveRecord
# Person.where(:confirmed => true).limit(5).pluck(:id)
#
def pluck(column_name)
+ if column_name.is_a?(Symbol) && column_names.include?(column_name.to_s)
+ column_name = "#{table_name}.#{column_name}"
+ end
klass.connection.select_all(select(column_name).arel).map! do |attributes|
klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes))
end