Add uniqueness validation to Reactions
This commit is contained in:
parent
8cdc0b28d3
commit
536d50f53d
|
@ -4,6 +4,8 @@ class Reaction < ApplicationRecord
|
||||||
belongs_to :parent, polymorphic: true
|
belongs_to :parent, polymorphic: true
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
validates_uniqueness_of :parent_id, :scope => :user_id
|
||||||
|
|
||||||
# rubocop:disable Rails/SkipsModelValidations
|
# rubocop:disable Rails/SkipsModelValidations
|
||||||
after_create do
|
after_create do
|
||||||
Notification.notify parent.user, self unless parent.user == user
|
Notification.notify parent.user, self unless parent.user == user
|
||||||
|
|
Loading…
Reference in New Issue