All threads / Will_paginate problems
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Will_paginate problems

kaine Wright asked in Rails
Hi ive been building a new web app based on michael hartl tutorial but im having problems with the will_paginate tests. 

When i load all my users it will display every one of them so of course i add gem will_paginate to gemfile and 
User.paginate(:page => params[:page], :per_page => 30)

 to my def index.  inside my index.html.erb i have 
<%= will_paginate %> 

This all works great i load the server and start to browse through my users page by page. Im not sure how its working though becuase in the tests i have this 

require 'test_helper'

class UsersIndexTest < ActionDispatch::IntegrationTest
  def setup
    @user = users(:michael)
  end

  test "index including pagination" do
    log_in_as(@user)
    get users_path
    puts @response.body
    assert 'users/index'
    assert_select 'div.paginate' #if i remove .paginate assert select test passes. but can not find the paginate code.
    User.paginate(page: 1, per_page: 10).each do |user|
      assert_select 'a[href=?]', user_path(user), text: user.username
    end
  end
end

if on the index.html.erb i add this instead 
<div class="paginate"> <%= will_paginate %> </div>

@response.body shows this <div class="paginate">  </div> but there should be another div paginate inside the written one. and if i remove the erb all together leaving the written div things still work. So im lost as to what is happening 

Thank you for such an excellent post and review; I am blown away! Continue to publish similar content.

In the slope unblocked game, you will control your ball as it navigates obstacles on an infinite slope. Naturally, the faster the ball rolls, the longer you live. Your score will increase by one for each successful 'jump.'

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 68,326+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.