class ActiveRecord::Reflection::ThroughReflection

:nodoc:
Holds all the meta-data about a :through association as it was specified in the Active Record class.

def check_validity!

def check_validity!
  if through_reflection.nil?
    raise HasManyThroughAssociationNotFoundError.new(active_record.name, self)
  end
  if source_reflection.nil?
    raise HasManyThroughSourceAssociationNotFoundError.new(self)
  end
  if options[:source_type] && source_reflection.options[:polymorphic].nil?
    raise HasManyThroughAssociationPointlessSourceTypeError.new(active_record.name, self, source_reflection)
  end
  if source_reflection.options[:polymorphic] && options[:source_type].nil?
    raise HasManyThroughAssociationPolymorphicError.new(active_record.name, self, source_reflection)
  end
  unless [:belongs_to, :has_many, :has_one].include?(source_reflection.macro) && source_reflection.options[:through].nil?
    raise HasManyThroughSourceAssociationMacroError.new(self)
  end
  check_validity_of_inverse!
end

def derive_class_name

def derive_class_name
  # get the class_name of the belongs_to association of the through reflection
  options[:source_type] || source_reflection.class_name
end

def source_reflection


end
has_many :tags, :through => :taggings
has_many :taggings
class Post < ActiveRecord::Base

(The :tags association on Tagging below.)
Gets the source of the through reflection. It checks both a singularized and pluralized form for :belongs_to or :has_many.
:nodoc:
Holds all the meta-data about a :through association as it was specified in the Active Record class.
def source_reflection
  @source_reflection ||= source_reflection_names.collect { |name| through_reflection.klass.reflect_on_association(name) }.compact.first
end

def source_reflection_names


[:singularized, :pluralized]

Gets an array of possible :through source reflection names:
def source_reflection_names
  @source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym }
end

def through_reflection


taggings_reflection = tags_reflection.through_reflection
tags_reflection = Post.reflect_on_association(:tags)

end
has_many :tags, :through => :taggings
has_many :taggings
class Post < ActiveRecord::Base

of a HasManyThrough or HasOneThrough association. Example:
Returns the AssociationReflection object specified in the :through option
def through_reflection
  @through_reflection ||= active_record.reflect_on_association(options[:through])
end

def through_reflection_primary_key

def through_reflection_primary_key
  through_reflection.belongs_to? ? through_reflection.klass.primary_key : through_reflection.primary_key_name
end

def through_reflection_primary_key_name

def through_reflection_primary_key_name
  through_reflection.primary_key_name if through_reflection.belongs_to?
end