From 536d50f53d7357e22dfb6ab8f3105872455e300e Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 19 Mar 2024 22:03:28 +0100 Subject: [PATCH] Add uniqueness validation to Reactions --- app/models/reaction.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/reaction.rb b/app/models/reaction.rb index 17bfb8c8..4a40e325 100644 --- a/app/models/reaction.rb +++ b/app/models/reaction.rb @@ -4,6 +4,8 @@ class Reaction < ApplicationRecord belongs_to :parent, polymorphic: true belongs_to :user + validates_uniqueness_of :parent_id, :scope => :user_id + # rubocop:disable Rails/SkipsModelValidations after_create do Notification.notify parent.user, self unless parent.user == user