Created
December 30, 2015 18:06
-
-
Save SteveOscar/7cddc7eca7a48ccd04f5 to your computer and use it in GitHub Desktop.
Basic Polymorphic Association
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tag < ActiveRecord::Base | |
belongs_to :taggable, polymorphic: true | |
end | |
class Article < ActiveRecord::Base | |
has_many :tags, as: :taggable | |
end | |
class Newspaper < ActiveRecord::Base | |
has_many :tags, as: :taggable | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment