Validate uniqueness of answers for questions
This commit is contained in:
parent
0d34037dc7
commit
7b0a615193
|
@ -8,6 +8,8 @@ class Answer < ApplicationRecord
|
|||
has_many :subscriptions, dependent: :destroy
|
||||
has_many :comment_smiles, through: :comments, source: :smiles
|
||||
|
||||
validates :question_id, uniqueness: { scope: :user_id }
|
||||
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
after_create do
|
||||
Inbox.where(user: self.user, question: self.question).destroy_all
|
||||
|
|
Loading…
Reference in New Issue