class ActiveRecord::Reflection::ThroughReflection
def chain
# => [
tags_reflection.chain
tags_reflection = Post.reflect_on_association(:tags)
end
has_many :tags, through: :taggings
has_many :taggings
class Post < ActiveRecord::Base
[self] as its #chain.
reflection. The base case for the recursion is a normal association, which just returns
The chain is built by recursively calling #chain on the source reflection and the through
array corresponds to a table which will be part of the query for this association.
Returns an array of reflections which are involved in this association. Each item in the
def chain @chain ||= begin a = source_reflection.chain b = through_reflection.chain chain = a + b chain[0] = self # Use self so we don't lose the information from :source_type chain end end