Skip to content

Instantly share code, notes, and snippets.

@fayimora
Forked from davidcelis/post.rb
Created February 23, 2012 01:04
Show Gist options
  • Save fayimora/1888911 to your computer and use it in GitHub Desktop.
Save fayimora/1888911 to your computer and use it in GitHub Desktop.
Polymorphism 101
class Post < ActiveRecord::Base
has_many :tag_links
has_many :tags, :through => :tag_links
# ...
end
class Project < ActiveRecord::Base
has_many :tag_links
has_many :tags, :through => :tag_links
# ...
end
# Schema info:
#
# t.string :name
class Tag < ActiveRecord::Base
has_many :tag_links
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment