# frozen_string_literal: true # == Schema Information # # Table name: post_taggings # # post_id :bigint not null, primary key # tag_id :bigint not null, primary key # # Indexes # # index_post_taggings_on_post_id_and_tag_id (post_id,tag_id) UNIQUE # index_post_taggings_on_tag_id (tag_id) # # Foreign Keys # # fk_rails_... (post_id => posts.id) # fk_rails_... (tag_id => tags.id) ON DELETE => cascade ON UPDATE => cascade # class Post::Tagging < ApplicationRecord self.primary_keys = :post_id, :tag_id belongs_to :post belongs_to :tag validates :tag, uniqueness: { scope: [:post_id] } end