Class: ActiveRecord::HasManyThroughSourceAssociationNotFoundError

Inherits:
ActiveRecordError
  • Object
show all
Defined in:
lib/active_record/associations.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(reflection) ⇒ HasManyThroughSourceAssociationNotFoundError

Returns a new instance of HasManyThroughSourceAssociationNotFoundError.



35
36
37
38
39
40
# File 'lib/active_record/associations.rb', line 35

def initialize(reflection)
  @reflection              = reflection
  @through_reflection      = reflection.through_reflection
  @source_reflection_names = reflection.source_reflection_names
  @source_associations     = reflection.through_reflection.klass.reflect_on_all_associations.collect { |a| a.name.inspect }
end

Instance Method Details

#messageObject



42
43
44
# File 'lib/active_record/associations.rb', line 42

def message
  "Could not find the source association(s) #{@source_reflection_names.collect(&:inspect).to_sentence :connector => 'or'} in model #{@through_reflection.klass}.  Try 'has_many #{@reflection.name.inspect}, :through => #{@through_reflection.name.inspect}, :source => <name>'.  Is it one of #{@source_associations.to_sentence :connector => 'or'}?"
end