Prevent an object from being destroyed in HABTM relationship

Hello all,

I have the following models:

class Sku < ActiveRecord::Base
has_and_belongs_to_many :options
end
class Option < ActiveRecord::Base
has_and_belongs_to_many :skus
end

By default if I destroy an Option any relationships between Options and
Skus will be removed as well.

But, I want to prevent an Option from being destroyed when it is
associated with a Sku in the options_skus table. So the only way to
destroy an Option is to first remove each relationship. Is this
possible to do in the model? Is there a particular Rails way to do it?

Thanks for any help or suggestions you may have!

Ian N.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs