diff options
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 1429f44ff3..f4756ed18d 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -952,7 +952,7 @@ module ActiveRecord fields = res.fields rows = results.map do |row| hashed_row = {} - row.each_index do |cell_index| + row.each_with_index do |cell, cell_index| # If this is a money type column and there are any currency symbols, # then strip them off. Indeed it would be prettier to do this in # PostgreSQLColumn.string_to_decimal but would break form input @@ -962,15 +962,15 @@ module ActiveRecord # cases to consider (note the decimal separators): # (1) $12,345,678.12 # (2) $12.345.678,12 - case column = row[cell_index] + case cell when /^-?\D+[\d,]+\.\d{2}$/ # (1) - row[cell_index] = column.gsub(/[^-\d\.]/, '') + row[cell_index] = cell.gsub(/[^-\d\.]/, '') when /^-?\D+[\d\.]+,\d{2}$/ # (2) - row[cell_index] = column.gsub(/[^-\d,]/, '').sub(/,/, '.') + row[cell_index] = cell.gsub(/[^-\d,]/, '').sub(/,/, '.') end end - hashed_row[fields[cell_index]] = column + hashed_row[fields[cell_index]] = cell end row end |