From cfb5f1b6083d4b0dabaaab70c383d223193811fd Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Tue, 31 May 2011 11:31:10 +0530 Subject: Fix nested attribute for memory record. --- .../lib/active_record/associations/collection_association.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 8a028c8996..17795f1b7d 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -402,7 +402,11 @@ module ActiveRecord return memory if persisted.empty? persisted.map! do |record| - 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| -- cgit v1.2.3 From 2e57b66931c9aa51cf41723e3ab691a550949a96 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Tue, 31 May 2011 12:12:19 +0530 Subject: Adding comment to work with 1.8.7. Nested Attribute fix. --- activerecord/lib/active_record/associations/collection_association.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 17795f1b7d..c32dd77420 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -402,6 +402,9 @@ module ActiveRecord return memory if persisted.empty? persisted.map! do |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) -- cgit v1.2.3 From e04f2c1d42bdc11f47a0f8c82fa1766ad89b7719 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Tue, 31 May 2011 12:35:37 +0530 Subject: Opening class CascadedEagerLoadingTest at once. --- .../test/cases/associations/cascaded_eager_loading_test.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'activerecord') 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') -- cgit v1.2.3