Skip to content

Instantly share code, notes, and snippets.

@BrianTheCoder
Created September 10, 2008 19:26
Show Gist options
  • Select an option

  • Save BrianTheCoder/10023 to your computer and use it in GitHub Desktop.

Select an option

Save BrianTheCoder/10023 to your computer and use it in GitHub Desktop.
before :save do
[
:contents,
:venues,
:states,
:cities,
:zips
].each do |klass|
self.send(klass).entries
many_to_many_model = self.class.relationships[klass].child_model
unless self.send(klass) == many_to_many_model.all(:publish_group_id => self.id)
many_to_many_model.all(:publish_group_id => self.id).destroy!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment