# frozen_string_literal: true # == Schema Information # # Table name: post_hides # # created_at :datetime not null # post_id :bigint not null, primary key # user_id :bigint not null, primary key # # Indexes # # index_post_hides_on_post_id_and_user_id (post_id,user_id) UNIQUE # index_post_hides_on_user_id (user_id) # # Foreign Keys # # fk_rails_... (post_id => posts.id) # fk_rails_... (user_id => users.id) ON DELETE => restrict ON UPDATE => cascade # class Post::Hide < ApplicationRecord self.primary_keys = :post_id, :user_id belongs_to :post, counter_cache: true belongs_to :user validates :user_id, uniqueness: { scope: [:post_id] } end