Getting Will_Pagination to work with Devise + acts_as_votable

228 Views Asked by At

I'd like to enable signed-in users the ability vote on items and visit a page that lists all their votes in a paginated format. Currently clicking on the pagination links doesn't update the content, though will_paginate accurately knows how many links to render.

In other words if there are 15 voted on items, and will_paginate specifies outputting 5 items per page, I will see 3 will_paginate links. However clicking on the link doesn't update the content (I'm stuck on page 1). Any help would be much appreciated thanks.

In Controller

require 'will_paginate/array'
def myfaves
   @user_likes = current_user.find_liked_items.paginate(:page => params[:page], :per_page => 5)
end

In View

<%= will_paginate @user_likes %>
1

There are 1 best solutions below

0
On

I figured out the issue, in View when rendering items to the page I had to call <% @user_likes.each do |songs| %> This ensures <%= will_paginate @user_likes %> is tied to the items rendered on the page.