无法删除只读的关联

时间:2016-06-28 15:34:57

标签: ruby-on-rails

我有3张桌子

class Product < ApplicationRecord
   has_many :accessories
   has_many :product_attribute_categories, through: :accessories, dependent: :destroy
end 

class Accessory < ApplicationRecord
  belongs_to :product
  belongs_to :product_attribute_category
end


class ProductAttributeCategory < ApplicationRecord
  has_many :accessories, dependent: :destroy
  has_many :products, through: :accessories
  has_many :product_attributes, dependent: :destroy

现在当我尝试删除ProductAttributeCategory时,我希望删除与之关联的所有accessories。所以它不会返回任何错误。

然而它返回Accessory is marked as readonly。所以我想知道我所做的事情是不是最优的,而是我应该做些什么。

0 个答案:

没有答案