added User#answered?

This commit is contained in:
nilsding 2015-01-03 18:40:56 +01:00
parent 7be7de11cd
commit 496ff61a65
1 changed files with 7 additions and 0 deletions

View File

@ -101,6 +101,13 @@ class User < ActiveRecord::Base
question: question) question: question)
end 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 # smiles an answer
# @param answer [Answer] the answer to smile # @param answer [Answer] the answer to smile
def smile(answer) def smile(answer)