Skip to content

Instantly share code, notes, and snippets.

@Ferdev
Created September 27, 2010 10:37
Show Gist options
  • Save Ferdev/598842 to your computer and use it in GitHub Desktop.
Save Ferdev/598842 to your computer and use it in GitHub Desktop.
class Animal < ActiveRecord::Base
has_many :diseases
has_many :pets
end
class Disease < ActiveRecord::Base
belongs_to :animal
has_and_belongs_to_many :pets
end
class Pet < ActiveRecord::Base
belongs_to :animal
has_and_belongs_to_many :diseases
accepts_nested_attributes_for :diseases, :allow_destroy => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment