title: one model that connects two entries of another model
body: <p>Dear all (first post on stackoverflow),</p>
  
  <p>I would like to connect two entries of the Model Molecule via the Model Interaction and build synchronous association. </p>
  
  <p>When I create an interaction between say molecule 1 and molecule 2 by Interaction.create(molecule_id=1, partner_id=2), the interaction is only added to molecule 1.
  I would like to have the interaction being saved to each of the molecules. 
  A workaround by adding subsequently adding an interaction to molecule 2 with swapped id parameters does not make sense.</p>
  
  <p>Model Molecule:
  </p>
  
  <pre><code>class Molecule &lt; ActiveRecord::Base
  
    has_many :interactions
    has_many :partners, through: :interactions
  
  end
  </code></pre>
  
  
  
  <p>Model Interaction:
  </p>
  
  <pre><code>class Interaction &lt; ActiveRecord::Base
    belongs_to :molecule
    belongs_to :partner, :class_name =&gt; 'Molecule'
  
  end
  </code></pre>
  
  
  
  <p>Interactions Migration File:
  </p>
  
  <pre><code>class CreateInteractions &lt; ActiveRecord::Migration
    def change
      create_table :interactions do |t|
       t.belongs_to :molecule
       t.belongs_to :host,  class: 'Molecule'
       t.timestamps null: false
      end
    end
  end
  </code></pre>
  
  <p>I hope the post is correct at this position and well formated. Please tell me if I am supposed to provide more information. I surely I hope one of you can help me finding a decent solution for that problem. Thanks and best regards,
  Stephan </p>