title: Count records for Blog in Ruby on Rails - Easy Question
body: <p>I am new to rails so sorry for the simple question. I have followed several tutorials and set up a blog with comments (even using a little AJAX - Ha proud of myself). I have done some customizing and right now I am trying to display in the index.html.erb a comment count that is a clickable link that takes to you the show.html.erb page. Here is what I did so far and not sure it is right. In the comments_controller I have added the following:</p>
  
  <pre><code>  def count
      @post = Post.find(params[:post_id])
      @comment = @post.comments.count(params[:comment])
    end
  </code></pre>
  
  <p>First question is this the correct def to count comments associated with a particular post. Second question is how do I then call it in my index.html.erb page where I have the following:</p>
  
  <pre><code>&lt;% @posts.each do |post| %&gt;
    &lt;%= render :partial =&gt; post %&gt;
    &lt;%= link_to 'View &amp; Add Comments', post %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>As you can see I am currently using a link_to reference to get to the page but ideally would like it to show something like: Comments (8). </p>