diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-22 19:22:59 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-22 19:23:27 +0000 |
commit | 16dbe1db1eb0ebf6111d9938b88d1f0652b78734 (patch) | |
tree | d9c663d3487d5e783ebfa05d5f170f9f92f04626 /activerecord/lib/active_record/relation | |
parent | c1d3e66858cee041df16a2338a5c75a637b30148 (diff) | |
download | rails-16dbe1db1eb0ebf6111d9938b88d1f0652b78734.tar.gz rails-16dbe1db1eb0ebf6111d9938b88d1f0652b78734.tar.bz2 rails-16dbe1db1eb0ebf6111d9938b88d1f0652b78734.zip |
Make ActiveRecord::Relation#pluck work with serialized attributes
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 0f57e9831d..0d60810cd2 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -168,7 +168,7 @@ module ActiveRecord # This method is designed to perform select by a single column as direct SQL query # Returns <tt>Array</tt> with values of the specified column name - # The values has same data type as column. + # The values has same data type as column. # # Examples: # @@ -177,9 +177,9 @@ module ActiveRecord # Person.where(:confirmed => true).limit(5).pluck(:id) # def pluck(column_name) - scope = self.select(column_name) - self.connection.select_values(scope.to_sql).map! do |value| - type_cast_using_column(value, column_for(column_name)) + column_name = column_name.to_s + klass.connection.select_all(select(column_name).arel).map! do |attributes| + klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes)) end end |