aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb2
-rw-r--r--activerecord/lib/active_record/associations/association_proxy.rb4
-rw-r--r--activerecord/lib/active_record/associations/belongs_to_association.rb6
-rw-r--r--activerecord/lib/active_record/associations/through_association.rb2
4 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 0959ea2c5a..be5d264a8f 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -364,7 +364,7 @@ module ActiveRecord
end
def load_target
- if !@owner.new_record? || foreign_key_present
+ if !@owner.new_record? || foreign_key_present?
begin
unless loaded?
if @target.is_a?(Array) && @target.any?
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb
index 65fef81d64..e86f4c0283 100644
--- a/activerecord/lib/active_record/associations/association_proxy.rb
+++ b/activerecord/lib/active_record/associations/association_proxy.rb
@@ -270,7 +270,7 @@ module ActiveRecord
def load_target
return nil unless defined?(@loaded)
- if !loaded? && (!@owner.new_record? || foreign_key_present) && @scope
+ if !loaded? && (!@owner.new_record? || foreign_key_present?) && @scope
@target = find_target
end
@@ -287,7 +287,7 @@ module ActiveRecord
#
# Currently implemented by belongs_to (vanilla and polymorphic) and
# has_one/has_many :through associations which go through a belongs_to
- def foreign_key_present
+ def foreign_key_present?
false
end
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb
index c54e397ae4..98b846f97c 100644
--- a/activerecord/lib/active_record/associations/belongs_to_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -38,7 +38,7 @@ module ActiveRecord
record.class.increment_counter(counter_cache_name, record.id)
end
- if foreign_key_present
+ if foreign_key_present?
target_klass.decrement_counter(counter_cache_name, target_id)
end
end
@@ -55,7 +55,7 @@ module ActiveRecord
end
def find_target
- if foreign_key_present
+ if foreign_key_present?
scoped.first.tap { |record| set_inverse_instance(record) }
end
end
@@ -77,7 +77,7 @@ module ActiveRecord
conditions
end
- def foreign_key_present
+ def foreign_key_present?
!@owner[@reflection.foreign_key].nil?
end
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb
index 0d83b46130..2b28dda363 100644
--- a/activerecord/lib/active_record/associations/through_association.rb
+++ b/activerecord/lib/active_record/associations/through_association.rb
@@ -152,7 +152,7 @@ module ActiveRecord
end
end
- def foreign_key_present
+ def foreign_key_present?
@reflection.through_reflection.macro == :belongs_to &&
!@owner[@reflection.through_reflection.foreign_key].nil?
end