I have this code…
User.find :all,
:select => "users.id, departments.name, users.username, response_sets.id AS 'response_set_id', response_sets.survey_id, COUNT(responses.id) AS 'answers', response_sets.completed_at",
:joins => "LEFT JOIN departments ON users.department_id = departments.id LEFT JOIN versions ON departments.version_id = versions.id LEFT JOIN response_sets ON users.id = response_sets.user_id AND versions.survey_id = response_sets.survey_id LEFT JOIN responses ON response_sets.id = responses.response_set_id AND responses.answer_id IS NOT NULL",
:conditions => {:id => 4},
:group => "users.id"
And all it’s returning is this [#<User id: 4, username: "3333">] should there be more? because of my :select?? should I have use :include instead of :joins..still learning..newbie here! xP
There actually is more in all the instances but what you see is the result of a call to the method
inspectand that will only show the content of the actual columns from the User model. But if you try to call the other values returned by your statement you should be able to see the result. For example: