Method: ActiveRecord::Reflection::ThroughReflection#source_reflection

Defined in:
lib/active_record/reflection.rb

#source_reflectionObject

Gets the source of the through reflection. It checks both a singularized and pluralized form for :belongs_to or :has_many.

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


345
346
347
# File 'lib/active_record/reflection.rb', line 345

def source_reflection
  @source_reflection ||= source_reflection_names.collect { |name| through_reflection.klass.reflect_on_association(name) }.compact.first
end