class ImageTag < ApplicationRecord belongs_to :image belongs_to :tag # Ensure uniqueness of tag per image validates :tag_id, uniqueness: { scope: :image_id } end