aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorFranck Verrot <franck@verrot.fr>2011-07-19 17:32:16 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2011-07-20 15:40:01 -0700
commit8bc314b3b7dca6d3c796760ace1bb9c1d4cadf53 (patch)
tree01f07d52f34d880e164e50fbc5a4f2aa2252b353 /activerecord/lib
parentd8736b266b00e58b8f8f29259913d9306605da14 (diff)
downloadrails-8bc314b3b7dca6d3c796760ace1bb9c1d4cadf53.tar.gz
rails-8bc314b3b7dca6d3c796760ace1bb9c1d4cadf53.tar.bz2
rails-8bc314b3b7dca6d3c796760ace1bb9c1d4cadf53.zip
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.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb2
1 files changed, 1 insertions, 1 deletions
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