Hi Erwin,

I'm sorry I didn't see your first post.

On Sat, Apr 21, 2012 at 8:12 AM, Erwin <[email protected]> wrote:
<snip>

>> I would like to have a single line to get both, posted and commented
>> counts
<snip>

>> where am I wrong ?  thanks for feedback

Why do you want to count 2 separate / independent resources in one SQL
statement?  I'd bet a nickel that it's going to be less efficient from
a processing perspective, and it's certainly less readable than:

users = User.includes(:posts, :comments)
users.each do |u|
  puts u.id.to_s + u.posts.size.to_s + u.comments.size.to_s
end

Best regards,
Bill

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to