I am retrieving data on individual lines within a report with the following named_scope
in my survey_response.rb model:
named_scope :job_responses, lambda{|job_code, survey_code| {:conditions => ["survey_job_id = ? AND survey_id = ?", job_code, survey_code]}}
Checking the log I can see that my SQL query is executed as expected. The query returns a list of individual responses for a job survey including mainly numeric data which I need to perform calculations on. Specifically I need to pass the contents of certain fields to an additional method which gets the Standard Deviation of the data in a specific field however I don't understand how to do this.
The external method is called as:
<%= survey_response.standard_deviation([array here]) %>
Currently in my view for each line within the report I retrieve the data appropriate to that line as follows:
<% r = SurveyResponse.job_responses(survey_response.id, survey_response.survey_id) %>
My question is therefore how do I send the results of a specific field from the returned named_scope data, for example :base_pay, on to my function?
I have tried various different ways but I don't know the syntax to isolate the appropriate field.