title: will_paginate comments partial not rendering?
body: <p>I was following the instructions on the wiki for this gem:</p>
  
  <pre><code>https://github.com/mislav/will_paginate/wiki
  </code></pre>
  
  <p>And it works great for my listings controller :/ I was able to get them paginate but I have no idea how to get it work with my comments. My comments controller doesn't have a show method.</p>
  
  <pre><code>class CommentsController &lt; ApplicationController
    before_action :authenticate_user!, :except =&gt; [:show]
    def create
      @comment = Comment.new(params[comment_params])
      @comment.listing_id = params[:listing_id]
      @comment.user_id = current_user.id
      @comment.body = params[:comment][:body]
      if @comment.save
        flash[:success] = "Comment Successful."
        redirect_to listing_path(@comment.listing)
      else
        flash[:alert] = "Comment Failed."
      end
    end
    def destroy
      @comment = @listing.comments.find(params[:id])
      @comment.destroy
      flash[:success] = "Comment Removed."
      redirect_to listing_path(@listing)
    end
    private
    def comment_params
      params.require(:comment).permit(:user, :body)
    end
  end
  </code></pre>
  
  <p>This is the show method I have inside my ListingsController:</p>
  
  <pre><code>def show
     @comment = Comment.new
     @comment.listing_id = @listing_id
  end
  </code></pre>
  
  <p>It's what sets the comments to my understanding</p>
  
  <p>This is the listings/show.html.erb file's part where it renders the comments:</p>
  
  <pre><code>&lt;div class="commentblock"&gt;
    &lt;div class="text-left"&gt;
      &lt;%= render partial: 'comments/form' %&gt;
      &lt;%= render partial: 'listings/comment',  collection: @listing.comments.reverse %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I know the first part of ruby code actually renders the forms but I don't understand how or what the collection part works or how to apply the pagination to this.</p>
  
  <p>The listings/comment file looks like this:</p>
  
  <pre><code>&lt;div class="panel panel-default"&gt;
    &lt;div class="panel-heading"&gt;&lt;%= comment.user.username %&gt;: &lt;%= time_ago_in_words(comment.created_at)%&gt; ago&lt;/div&gt;
    &lt;div class="panel-body"&gt;
      &lt;%= comment.body %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I've tried quite a few things but I still don't really get where or what to change in my code. I went into the listing/comment and tried adding:</p>
  
  <pre><code>&lt;%= will_paginate(comment) %&gt; # this crashed, undefined method `total_pages' for #&lt;Comment:0x007ff556a36468&gt;
  </code></pre>
  
  <p>EDIT: The will_paginate wiki says you to pass a paginated array when you get the error I got, but I don't know that is done >.>; it doesn't show how you would do that...</p>
  
  <p>EDIT:
  <a href="http://csnipp.com/s/709" rel="nofollow">http://csnipp.com/s/709</a> this website said all you had to do was create a file config/initializers/will_paginate.rb and place this line of code in it:</p>
  
  <pre><code> require 'will_paginate/array'
  </code></pre>
  
  <p>But that didn't help </p>
  
  <p>EDIT:</p>
  
  <p>If you guys need to see more of the code it's actually on github:
  <a href="https://github.com/ilovemysillybanana/pastie/" rel="nofollow">https://github.com/ilovemysillybanana/pastie/</a></p>
  
  <p>I'm really stuck on this D: I followed a tutorial on how to make the comments but theirs didn't paginate.</p>
  
  <p>EDIT:
  I fixed it! </p>
  
  <p>The way to do it was by replacing this line:</p>
  
  <pre><code>&lt;%= render partial: 'listings/comment',  collection: @listing.comments.reverse %&gt;
  </code></pre>
  
  <p>with this line:</p>
  
  <pre><code>&lt;%= render partial: 'listings/comment',  collection: @list_comments = @listing.comments.paginate(:page =&gt; 1, :per_page =&gt; 5) %&gt;
  </code></pre>
  
  <p>But for some reason I don't get the numbers to change the comment pages :/ </p>