From b05fc40b5d096695dad5b3282664512d7509a529 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 1 Jun 2007 03:26:51 +0000 Subject: Calculations support non-numeric foreign keys. Closes #8154. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6919 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/calculations.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/calculations.rb') diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 09c0c979e6..ef59db915a 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -235,7 +235,8 @@ module ActiveRecord end calculated_data.inject(ActiveSupport::OrderedHash.new) do |all, row| - key = associated ? key_records[row[group_alias].to_i] : type_cast_calculated_value(row[group_alias], group_column) + key = type_cast_calculated_value(row[group_alias], group_column) + key = key_records[key] if associated value = row[aggregate_alias] all << [key, type_cast_calculated_value(value, column, operation)] end -- cgit v1.2.3