Will_paginate not rendering Ruby On Rails

1.1k views Asked by At

I have Will_Paginate installed on my app, and everything was working fine when suddenly i noticed that the link to the next pages were not showing up. Everything seems to be working fine other than that, no error messages or anything. using will_paginate v 3.0.7

here is my controller code

@apps = App.all.paginate(:page => params[:page], :per_page => 4).order(created_at: :desc)

here is my views

<%= will_paginate @apps, renderer: BootstrapPagination::Rails %>

Using will_paginate-bootstrap 1.0.1

in the HTML, there is simply nothing where the links should be rendered.

I've gone through every single troubleshooting step, and everything seems to be working perfectly, except the links are not showing up.

manually going to ?page=2 works, but I can't seem to get the buttons to show up.

2

There are 2 answers

1
Christian T On

Also for others in the future, make sure you have enough posts to require a second page. If you do not have enough posts, then paginate will not render.

This can be fixed by adding more posts, or lower the per_page requirement, below your total number of posts.

0
Juan Pablo Ugas On

Hopefully after 5 months you've solved this but in case someone else ends up with the same problem with will_paginate it does the .all work for you so your query can look like this:

@apps = App.paginate(:page => params[:page], :per_page => 4).order(created_at: :desc)

and above your table on your page views like this:

<%= will_paginate @apps %>

I ran into a few issues when trying to set it up, I'm pretty new to the gem as well...