自分用にメモ
User, Taggings, Tagというモデルがる。
UserはTaggingsをthrougして沢山のtagを持っている。
has_many :taggings, as: :taggable, dependent: :destroy
has_many :tags, through: :taggings
class Tagging < ActiveRecord::Base
belongs_to :tag
belongs_to :taggable, polymorphic: true
end
class Tag < ActiveRecord::Base
has_many :taggings, dependent: :destroy
has_many :users, through: :taggings, source: :taggable, source_type: 'User'
validates :name, presence: true
end