Ian Neubert
2006-Nov-08 23:42 UTC
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 Neubert --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---