From 496ff61a65489d42be07b46f502dc84305167408 Mon Sep 17 00:00:00 2001 From: nilsding Date: Sat, 3 Jan 2015 18:40:56 +0100 Subject: [PATCH] added User#answered? --- app/models/user.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 765ba67d..ca2a2182 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -101,6 +101,13 @@ class User < ActiveRecord::Base question: question) end + # has the user answered +question+ yet? + # @param question [Question] + def answered?(question) + question.answers.each { |a| return true if a.user_id == self.id } + false + end + # smiles an answer # @param answer [Answer] the answer to smile def smile(answer)