title: Rails Association working only one way
body: <p>My model "Preconditions" creates relationships between records in the "Assignments" model, so that one assignment can be a pre-requisite for another assignment. </p>
  
  <p>In the console, Assignment.find(3).preassigns outputs the second record from the Assignment table, as I expect. However, the inverse is not working. Assignment.find(2).mainassigns returns an empty set.</p>
  
  <p><strong>precondition.rb</strong></p>
  
  <pre><code>class Precondition &lt; ApplicationRecord
      belongs_to :mainassign, class_name: "Assignment"
      belongs_to :preassign, class_name: "Assignment"
  end
  </code></pre>
  
  <p><strong>assignment.rb</strong></p>
  
  <pre><code>class Assignment &lt; ApplicationRecord
      belongs_to  :seminar
      has_many    :scores, dependent: :destroy
  
      has_many    :preconditions, class_name: "Precondition",
                                  foreign_key: "mainassign_id",
                                  dependent: :destroy
      has_many    :mainconditions, class_name: "Precondition",
                                  foreign_key: "preassign_id",
                                  dependent: :destroy
  
      has_many    :preassigns, through: :preconditions, as: :mainassign, source: :preassign
      has_many    :mainassigns, through: :preconditions, as: :preassign, source: :mainassign
  
      validates :name, presence: true, length: { maximum: 40 }
      validates :seminar_id, presence: true
      validates :possible, presence: true
      validates_numericality_of   :possible, only_integer: true
  end
  </code></pre>
  
  <p>Based on similar questions, I've tried adding a polymorphic tag in the Preconditions table, like so:</p>
  
  <pre><code>belongs_to :mainassign, class_name: "Assignment", polymorphic: true
  </code></pre>
  
  <p>This caused an error, but the log suggested that I try a source_type, so I tried adding that to the assignments model, like so:</p>
  
  <pre><code>has_many    :mainassigns, through: :preconditions, as: :preassign, source: :mainassign, source_type: "Assignment"
  </code></pre>
  
  <p>But that resulted in an SQL column not found error.</p>
  
  <p>Thank you in advance for any insight.</p>