title: Two different classes using accepts_nested_attributes of one class
body: <p>I have a class Addresse where Organismereferent and Organisme have a <code>has_many</code> <code>belongs_to</code> relationship with. Also Organismereferent and Organisme can <code>accepts_nested_attributes_for :addresses</code></p>
  
  <p>My problem is when I only had the Organismereferent class everything was working fine and I was able to create a new Organismereferent with an addresse but as soon as I created and added the same relation to Organisme , they both stopped working without giving any error message I only get this in the console:
  <a href="https://i.stack.imgur.com/8sOMg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8sOMg.png" alt="enter image description here"></a></p>
  
  <p>My model:</p>
  
  <pre><code>class Organismereferent &lt; ApplicationRecord
    has_many :addresses
    has_many :referents
    accepts_nested_attributes_for :addresses
  end
  
  class Organisme &lt; ApplicationRecord
    has_many :addresses
    accepts_nested_attributes_for :addresses
  end
  
  class Address &lt; ApplicationRecord
    belongs_to :organismereferent
    belongs_to :organisme
  end
  </code></pre>
  
  <p>Controller for Organisme</p>
  
  <pre><code>def new
    @organisme = Organisme.new
    @organisme.addresses.build
  end
  
  def create
    @organisme = Organisme.new(organisme_params)
    @organisme.status = true
    @organisme.save
    redirect_to @organisme
  end
  
  private
    def organisme_params
      params.require(:organisme).permit(:nom, :telephone, :courriel, :fax, addresses_attributes: [:id, :no_civique, :rue, :ville, :province, :etat, :code_postal])
    end
  </code></pre>
  
  <p>Controller for Organismereferent:</p>
  
  <pre><code>def new
    @organisme = Organismereferent.new
    @organisme.addresses.build
  end
  
  def create
    @organisme = Organismereferent.new(organisme_params)
    @organisme.active = true
    @organisme.save
    redirect_to @organisme
  end
  
  private
    def organisme_params
        params.require(:organismereferent).permit(:nom_organisation, :bureau, :telecopie, :courriel, :site_web, addresses_attributes: [:id, :no_civique, :rue, :ville, :province, :etat, :code_postal])
    end
  </code></pre>
  
  <p>I'm not sure what else information might be important so I'll be glad to add anything.</p>