I am attempting to call Comment.get_collected_data_by() with a specific office. This method's purpose is to aggregate a bunch of data together into an array (data). I need it to create a hash of aggregated data per respondent.
To hopefully make database calls minimal, I am pulling all the data I need in the 3 calls:
- respondents = Respondent.completed.find_all_by_office_id(location)
- answers = Answer.find_all_by_respondent_id(respondents)
- comments = find_all_by_respondent_id(respondents)
I then enumerate through respondents and I need to grab just the answers of that respondent. Is there an easy way to grab them out of the answers variable?
What I could do is create this:
This would create a hash that I can easily pull answers from given a respondent_id. This doesnt seem like the best way to do this.