That did it.  I think I've been staring at the monitor too
long...  :-)

On Sep 18, 2:34 am, Gourav <[email protected]> wrote:
> I think, you must have Post-'has many"-Comments relationship
>
> So, to find number of comments:
> post.comments.count will give you total number of comments of a post.
>
> -Gourav
>
> On Sep 18, 10:58 am, Mark <[email protected]> wrote:
>
> > I have "posts"  and "comments", and I'd like to display the number of
> > comments each post has (and display 0 if none).  In the index Posts
> > view, I display a list of posts and their authors using the below
> > partial.  What I can't figure out is how to limit the comment count to
> > the post listing (my attempts so far show the total number of comments
> > in the database).  How do I limit the count?
>
> > partial:
>
> > <% div_for post do %>
> >         <p><strong><%= link_to_unless_current h(post.title), post 
> > %></strong>
> > -
> >                 <font size="1">created by <%= post.user %> <%= 
> > time_ago_in_words
> > (post.created_at) %> ago
> >                 </font><br />
> >         <%= post.body %></p>
> > <% end %>
>
> > Many thanks!
> > Mark
--~--~---------~--~----~------------~-------~--~----~
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