On Mon, May 10, 2010 at 7:37 PM, David Zhu dzwestwindso...@gmail.com wrote:
Thanks guys,
If I have nested associations, how could i count that? For ex-
I want to do something like @totalcount = Post.comment.count , or
something like that
How could i do that? ( i want to count the comments
Thank you,
I swear this is the last question about this-
Is there a way to go one level deeper, so instead of @totalcount =
Post.comments.count, could I have lets say... ---
@totalcount = Post.comments.davids.count, if comments has many davids?
So basically instead of just post has many
On May 11, 2010, at 7:47 AM, David Zhu wrote:
Thank you,
I swear this is the last question about this-
Is there a way to go one level deeper, so instead of @totalcount =
Post.comments.count, could I have lets say... ---
@totalcount = Post.comments.davids.count, if comments has many davids?
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
On 11 May 2010 13:32, David Zhu dzwestwindso...@gmail.com wrote:
Oh ok thanks!
But just to make sure we are on the same page-
Page has many comments
Comments has many Davids
I believe that if you also say Page has_many davids through comments
then you can get at all the davids for a post by
i need a join table? is the join table my comments table?
On May 11, 8:36 am, Colin Law clan...@googlemail.com wrote:
On 11 May 2010 13:32, David Zhu dzwestwindso...@gmail.com wrote:
Oh ok thanks!
But just to make sure we are on the same page-
Page has many comments
Comments has many
On Tue, May 11, 2010 at 8:43 AM, David Zhu dzwestwindso...@gmail.com wrote:
On May 11, 8:36 am, Colin Law clan...@googlemail.com wrote:
I believe that if you also say Page has_many davids through comments
then you can get at all the davids for a post by
@post.davids
and hence you can use
On 11 May 2010 13:43, David Zhu dzwestwindso...@gmail.com wrote:
i need a join table? is the join table my comments table?
It already is a join table, you just need to tell rails that it can
use it as such.
By the way could you not top post (so insert your comments at the
appropriate point in
On May 11, 9:32 am, Colin Law clan...@googlemail.com wrote:
On 11 May 2010 13:43, David Zhu dzwestwindso...@gmail.com wrote:
i need a join table? is the join table my comments table?
It already is a join table, you just need to tell rails that it can
use it as such.
By the way could you
[long post intentionally not snipped so the comments at the end make sense]
On 11 May 2010 21:11, David Zhu dzwestwindso...@gmail.com wrote:
On May 11, 9:32 am, Colin Law clan...@googlemail.com wrote:
On 11 May 2010 13:43, David Zhu dzwestwindso...@gmail.com wrote:
i need a join table? is
On 11 May 2010 21:11, David Zhu dzwestwindso...@gmail.com wrote:
about not top posting, is this top posting?
No. But it wasn't at the appropriate place in text. Making people
scroll through pages of footers to get to your question won't incline
them to answer you in future... just a thought.
--
Thanks guys,
If I have nested associations, how could i count that? For ex-
I want to do something like @totalcount = Post.comment.count , or
something like that
How could i do that? ( i want to count the comments that belong to
that post)
thanks
On Apr 29, 5:07 pm, Philip Hallstrom
David Zhu wrote:
Is it possible to do a find all, and then return the # of items?
Better to use the built-in aggregate functions.
http://railsapi.com/doc/rails-v2.3.5/classes/ActiveRecord/Calculations/ClassMethods.html#M001357
This will perform the count in SQL and will be much more efficient
On Apr 29, 2010, at 2:01 PM, Robert Walker wrote:
David Zhu wrote:
Is it possible to do a find all, and then return the # of items?
Better to use the built-in aggregate functions.
http://railsapi.com/doc/rails-v2.3.5/classes/ActiveRecord/Calculations/ClassMethods.html#M001357
This will
14 matches
Mail list logo