我得不到的东西……
我的模型中有这个:
- class Model < ActiveRecord::Base
- has_many :model_options # a link table for many to many
- has_many :options,:through => :model_options,:dependent => :destroy,:foreign_key => 'model_id'
- end
我试着这样做:
- model = Model.find(id)
- model.options.delete # also tried model.options.delete_all
- model.options.each do |option|
- option.delete
- end
……这不是最好的方式.
请问最好的方法是什么?
解决方法
- model.options.clear