Created
October 4, 2013 23:08
-
-
Save jeffnv/6834333 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def results | |
responses = Question.joins(<<-SQL) | |
LEFT OUTER JOIN answer_choices | |
ON answer_choices.question_id = questions.id | |
LEFT OUTER JOIN responses | |
ON answer_choices.id = responses.answer_choice_id | |
SQL | |
responses = responses.where("questions.id = ?", self.id) | |
p responses | |
responses.group('answer_choices.answer_body').count('responses.id') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment