diff options
Diffstat (limited to 'activerecord/lib/active_record/associations')
4 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 95526be82f..50c69abefb 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -371,7 +371,7 @@ module ActiveRecord @target = merge_target_lists(targets, @target) end - loaded + loaded! target end diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index ead2c5ede2..8e16246e80 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -128,7 +128,7 @@ module ActiveRecord end # Asserts the \target has been loaded setting the \loaded flag to +true+. - def loaded + def loaded! @loaded = true @stale_state = stale_state end @@ -152,7 +152,7 @@ module ActiveRecord # Sets the target of this proxy to <tt>\target</tt>, and the \loaded flag to +true+. def target=(target) @target = target - loaded + loaded! end # Forwards the call to the target. Loads the \target if needed. @@ -227,7 +227,7 @@ module ActiveRecord # not reraised. The proxy is \reset and +nil+ is the return value. def load_target @target = find_target if find_target? - loaded + loaded! target rescue ActiveRecord::RecordNotFound reset diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb index cb3edafab1..fdd4fe8946 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb @@ -210,7 +210,7 @@ module ActiveRecord case macro when :has_many, :has_and_belongs_to_many collection = record.send(join_part.reflection.name) - collection.loaded + collection.loaded! collection.target.push(association) collection.send(:set_inverse_instance, association) when :belongs_to diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 002e1a9ae8..caefd14ee3 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -40,7 +40,7 @@ module ActiveRecord # If there's nothing in the database and @target has no new records # we are certain the current target is an empty array. This is a # documented side-effect of the method that may avoid an extra SELECT. - @target ||= [] and loaded if count == 0 + @target ||= [] and loaded! if count == 0 [@reflection.options[:limit], count].compact.min end |