aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-05-31 08:46:27 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-05-31 08:46:27 -0700
commit021e4f16b7db21d397196d9e1c1a693935e1e371 (patch)
tree0581aef18ecaa32f19736bf7aac2997aa2d3316c
parent12786518f1f712e32d850c09de22635823533500 (diff)
parente04f2c1d42bdc11f47a0f8c82fa1766ad89b7719 (diff)
downloadrails-021e4f16b7db21d397196d9e1c1a693935e1e371.tar.gz
rails-021e4f16b7db21d397196d9e1c1a693935e1e371.tar.bz2
rails-021e4f16b7db21d397196d9e1c1a693935e1e371.zip
Merge pull request #1417 from arunagw/nested_attributes_fix
Fix nested attribute for memory record.
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb9
-rw-r--r--activerecord/test/cases/associations/cascaded_eager_loading_test.rb10
2 files changed, 11 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 8a028c8996..c32dd77420 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -402,7 +402,14 @@ module ActiveRecord
return memory if persisted.empty?
persisted.map! do |record|
- mem_record = memory.delete(record)
+
+ # To work with ruby 1.8.7
+ # > 1.9 #=> mem_record = memory.delete(record)
+ mem_record_index = memory.index(record)
+ if mem_record_index
+ mem_record = memory.at(mem_record_index)
+ memory.delete_at(mem_record_index)
+ end
if mem_record
(record.attribute_names - mem_record.changes.keys).each do |name|
diff --git a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
index 49d8722aff..ff376a68d8 100644
--- a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
+++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
@@ -8,10 +8,12 @@ require 'models/company'
require 'models/topic'
require 'models/reply'
require 'models/person'
+require 'models/vertex'
+require 'models/edge'
class CascadedEagerLoadingTest < ActiveRecord::TestCase
fixtures :authors, :mixins, :companies, :posts, :topics, :accounts, :comments,
- :categorizations, :people, :categories
+ :categorizations, :people, :categories, :edges, :vertices
def test_eager_association_loading_with_cascaded_two_levels
authors = Author.find(:all, :include=>{:posts=>:comments}, :order=>"authors.id")
@@ -164,12 +166,6 @@ class CascadedEagerLoadingTest < ActiveRecord::TestCase
authors[2].post_about_thinking.comments.first
end
end
-end
-
-require 'models/vertex'
-require 'models/edge'
-class CascadedEagerLoadingTest < ActiveRecord::TestCase
- fixtures :edges, :vertices
def test_eager_association_loading_with_recursive_cascading_four_levels_has_many_through
source = Vertex.find(:first, :include=>{:sinks=>{:sinks=>{:sinks=>:sinks}}}, :order => 'vertices.id')