I am pulling all respondents for an office. With each respondent I need to pull out an answer to a specific question. How can I do that?
respondent.answers is an array of answers, how do I grab only the member that has a certain question_id?
data = []
respondents = Respondent.completed.includes([:office, :answers]).find_all_by_office_id(office)
respondents.each do |respondent|
hash = {
office: respondent.office.name,
name: respondent.name,
#nps_value: respondent.answers ...,
}
data << hash
end