Something I'm not getting...
I have this in my model:
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
And I try to do this:
model = Model.find(id)
model.options.delete # also tried model.options.delete_all
But this is not deleting the records from the DB. Instead I'm having to do this:
model.options.each do |option|
option.delete
end
...which can't be the best way. So what is the best way, please?
Thanks