title: Delete in Many to Many Relationship Not Symmetric?
body: <p>I have two Models, Product and Category, and a join table, Categorizations, for the many-to-many relationship.</p>
  
  <p>Let's say I have two objects, product and category, that are instances of the above.</p>
  
  <pre><code>products = Product.new(...)
  category = Category.new(...)
  product.categories &lt;&lt; category
  </code></pre>
  
  <p>This successfully creates the relationship in both directions in the rails console, so that:</p>
  
  <pre><code>product.categories
  category.products
  </code></pre>
  
  <p>are both nonempty. Next:</p>
  
  <pre><code>product.categories.delete category
  </code></pre>
  
  <p>will delete the value from the product object and the join table. HOWEVER it will <em>not</em> delete it from the category object, so that:</p>
  
  <pre><code>category.products
  </code></pre>
  
  <p>is nonempty, which means that the in-memory category.products object is out of sync with the actual database. It seems weird to me that creation would work symmetrically but deletion would not.</p>
  
  <p>Here are the relevant models:</p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    has_many :categorizations, dependent: :destroy
    has_many :categories, through: :categorizations, :uniq =&gt; true
  end
  
  class Category &lt; ActiveRecord::Base
    has_many :categorizations, dependent: :destroy
    has_many :products, through: :categorizations, :uniq =&gt; true
  end
  
  class Categorization &lt; ActiveRecord::Base
    belongs_to :product, class_name: "Product"
    belongs_to :category, class_name: "Category"
  
    validates :product, presence: true
    validates :category, presence: true
  end
  </code></pre>
  
  <p>Any ideas? Thanks!</p>