Method: ActiveRecord::Reflection::ThroughReflection#source_reflection_name

Defined in:
activerecord/lib/active_record/reflection.rb

#source_reflection_nameObject

:nodoc:



889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
# File 'activerecord/lib/active_record/reflection.rb', line 889

def source_reflection_name # :nodoc:
  return @source_reflection_name if @source_reflection_name

  names = [name.to_s.singularize, name].collect(&:to_sym).uniq
  names = names.find_all { |n|
    through_reflection.klass._reflect_on_association(n)
  }

  if names.length > 1
    raise AmbiguousSourceReflectionForThroughAssociation.new(
      active_record.name,
      macro,
      name,
      options,
      source_reflection_names
    )
  end

  @source_reflection_name = names.first
end