Oh ok thanks!

But just to make sure we are on the same page-

Page has many comments
Comments has many Davids

Would

@davidcount = Post.comments.map {|comment| comment.davids.count}.sum

find out how many David's are in a certain Post?

Just to clarify, im not trying to find All of the David's that exsit
in the entire database, just the amount of Davids that belongs to the
post. But the part i dont understand is how to count up the David's
that belongs to that Post, because there are comments in between.
(post has many comments, comments has many davids) And i want to find
out for a certain post (@post) how many davds belongs to it)

So would @davidcount = Post.comments.map {|comment|
comment.davids.count}.sum  work for something like that?


Thank you

-- 
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