So I have a method in my User model that tries to determine if a user has answered a Question. A User has_many Answers, and a Question has_many Answers (through Choices). Here’s what I have so far:
def has_answered(question)
has_answered_question = false
answers.each { |answer|
has_answered_question = true if answer.question == question
}
has_answered_question
end
I was wondering if there’s any way to clean this up. It seems like there should be someway to do this without a boolean, and possibly in less lines than I’m currently doing it. The more suggestions / ways of doing this, the better. All suggestions welcome.
or