From 8bc314b3b7dca6d3c796760ace1bb9c1d4cadf53 Mon Sep 17 00:00:00 2001 From: Franck Verrot Date: Tue, 19 Jul 2011 17:32:16 +0200 Subject: assign_nested_attributes_for_collection_association should work with Ruby 1.9 [Closes #2106] Children attributes can be either String's or Symbol's, so let's check if the object responds to to_i. --- activerecord/lib/active_record/nested_attributes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index 53617059d0..69a8518ba0 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -383,7 +383,7 @@ module ActiveRecord attributes_collection = if keys.include?('id') || keys.include?(:id) Array.wrap(attributes_collection) else - attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes } + attributes_collection.sort_by { |i, _| i.respond_to?(:to_i) ? i.to_i : i.object_id }.map { |_, attributes| attributes } end end -- cgit v1.2.3