From 49c371302cc7af89efb600c625fc2a6e6a46c139 Mon Sep 17 00:00:00 2001 From: nilsding Date: Sun, 28 Dec 2014 22:15:25 +0100 Subject: [PATCH] unique smiles only! --- app/models/smile.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/smile.rb b/app/models/smile.rb index e94c1bd4..566c3bcc 100644 --- a/app/models/smile.rb +++ b/app/models/smile.rb @@ -1,7 +1,7 @@ class Smile < ActiveRecord::Base belongs_to :user belongs_to :answer - validates :user_id, presence: true + validates :user_id, presence: true, uniqueness: { scope: :answer_id, message: "already smiled answer" } validates :answer_id, presence: true after_create do