aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2012-02-08 16:37:27 +0200
committerBogdan Gusiev <agresso@gmail.com>2012-02-08 16:37:27 +0200
commita379cb2fb5c61f3108593ff96a74ca9c99300b09 (patch)
tree87963b7855db57e3935dd3227e14099be39fcc4b /activerecord/lib/active_record/relation
parent17497e5c557ce49f9fbaebf9a290b2a9fa216b8a (diff)
downloadrails-a379cb2fb5c61f3108593ff96a74ca9c99300b09.tar.gz
rails-a379cb2fb5c61f3108593ff96a74ca9c99300b09.tar.bz2
rails-a379cb2fb5c61f3108593ff96a74ca9c99300b09.zip
AR::Relation#pluck: improve to work with joins
Diffstat (limited to 'activerecord/lib/active_record/relation')
-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