Rails - join table deletion
<p>My Lab model:</p>

<pre><code>class Lab &lt; ApplicationRecord
    has_many :chain_offers, dependent: :delete_all
    has_many :offers, through: :chain_offers
</code></pre>

<p>My Join model (chain_offers)</p>

<pre><code>class ChainOffer &lt; ApplicationRecord
    belongs_to :lab
    belongs_to :offer
</code></pre>

<p>My Offer model</p>

<pre><code>class Offer &lt; ApplicationRecord
    has_many :chain_offers
    has_many :labs, through: :chain_offers
</code></pre>

<p>If I try to delete Lab, it gets delete, records in ChainOffer table are also deleted, but after checking <code>Offer.all.count</code> the count is still the same as before deletion.</p>

<p>Doing:</p>

<pre><code>place = Place.find(place_id)
place.offers.each do |offer|
    offer.destroy
end
place.destroy
</code></pre>

<p>solves that problem, but I was wondering if there is a way to set up associations so I do not have to write additional code.</p>