From 8c3e46c093023f9430c9772e81d58c9ee24de229 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 16 Mar 2010 11:26:19 -0700 Subject: clean up more warnings, remove unnecessary methods, fix eval line numbers. [#4193 state:resolved] Signed-off-by: wycats --- activerecord/lib/active_record/associations/has_many_association.rb | 4 ++++ activerecord/lib/active_record/attribute_methods/dirty.rb | 2 +- activerecord/lib/active_record/base.rb | 4 ++++ activerecord/lib/active_record/nested_attributes.rb | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 146a6ca55f..0464e8ceea 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -5,6 +5,10 @@ module ActiveRecord # If the association has a :through option further specialization # is provided by its child HasManyThroughAssociation. class HasManyAssociation < AssociationCollection #:nodoc: + def initialize(owner, reflection) + @finder_sql = nil + super + end protected def owner_quoted_id if @reflection.options[:primary_key] diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb index 4a3ab9ea82..64e761e7a4 100644 --- a/activerecord/lib/active_record/attribute_methods/dirty.rb +++ b/activerecord/lib/active_record/attribute_methods/dirty.rb @@ -34,7 +34,7 @@ module ActiveRecord # reload the record and clears changed attributes. def reload_with_dirty(*args) #:nodoc: reload_without_dirty(*args).tap do - previously_changed_attributes.clear + @previously_changed.clear changed_attributes.clear end end diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1488d9f967..3d4172f368 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1045,6 +1045,8 @@ module ActiveRecord #:nodoc: object.instance_variable_set(:@readonly, false) object.instance_variable_set(:@destroyed, false) object.instance_variable_set(:@marked_for_destruction, false) + object.instance_variable_set(:@previously_changed, {}) + object.instance_variable_set(:@changed_attributes, {}) object.send(:_run_find_callbacks) object.send(:_run_initialize_callbacks) @@ -1513,6 +1515,8 @@ module ActiveRecord #:nodoc: @readonly = false @destroyed = false @marked_for_destruction = false + @previously_changed = {} + @changed_attributes = {} ensure_proper_type diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index d8fae495e7..bc491c367f 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -243,11 +243,11 @@ module ActiveRecord # def pirate_attributes=(attributes) # assign_nested_attributes_for_one_to_one_association(:pirate, attributes) # end - class_eval %{ + class_eval <<-eoruby, __FILE__, __LINE__ + 1 def #{association_name}_attributes=(attributes) assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes) end - }, __FILE__, __LINE__ + eoruby else raise ArgumentError, "No association found for name `#{association_name}'. Has it been defined yet?" end -- cgit v1.2.3