Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def detect
# model lacks the next leg in the :through relationship. For
# instance, if user has many comments through posts then a nil
# source_reflection means that Post doesn't define +has_many :comments+.
if through?(association) && association.source_reflection.nil?
if association.through_reflection? && association.source_reflection.nil?
log("through association with nil source_reflection")

through_association = model.reflect_on_association(association.options.fetch(:through))
Expand All @@ -84,7 +84,7 @@ def detect
associated_models, associated_models_type =
if association.polymorphic?
[models_having_association_with_options(as: association.name), nil]
elsif through?(association)
elsif association.through_reflection?
[[association.source_reflection.active_record], "join"]
else
[[association.klass], nil]
Expand Down Expand Up @@ -159,10 +159,6 @@ def deletable?(model)
end
end

def through?(reflection)
reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
end

def defines_destroy_callbacks?(model)
# Destroying an associated model involves loading it first hence
# initialize and find are present. If they are defined on the model
Expand Down