Skip to content

Instantly share code, notes, and snippets.

View brentmc79's full-sized avatar

Brent Collier brentmc79

View GitHub Profile
class Tag < ActiveRecord::Base
has_many :taggings, :dependent => :destroy
has_many :books, :through => :tagings, :source => :taggable, :source_type => "Book"
has_many :movies, :through => :tagings, :source => :taggable, :source_type => "Movie"
end
class Book < ActiveRecord::Base
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings
end