Trouble with will_paginate method
Asked Answered
P

4

10

I'm trying to paginate with will_paginate in my rails app. I'm following the rails Tutorial by Michael Hartl. In my controller I have

def index
  @users = User.paginate(page: params[:page])
end

In my view I have

<%= will_paginate %>
<ul class="users">
  <% @users.each do |user| %>
    <li>
      <%= gravatar_for user, size: 50 %>
      <%= link_to user.name, user %>
    </li>
  <% end %>
</ul>
<%= will_paginate %>

It throws the following error : wrong number of arguments (given 0, expected 1) for will_paginate

Photobathic answered 17/4, 2019 at 10:23 Comment(0)
G
15

Had the same problem.

Change to 3.1.7 (from 3.1.6 in Gemfile) fixed it for me.

Ref. ArgumentError: wrong number of arguments (given 0, expected 1) #589

Gratt answered 17/4, 2019 at 13:50 Comment(0)
L
5

I had this problem and I browse some time to get the solution, the exact error that I got was :

enter image description here

The Solution

Go to the gemfile and change the gem 'will_paginate','3.1.6' to gem 'will_paginate','3.1.7'.

then go to the terminal and put bundle update

then the will paginate will work

enter image description here

Locklear answered 20/8, 2019 at 22:18 Comment(0)
X
4

I had just the same issue with different versions.

For my situation, changing from 3.1.8 to the latest version of 3.3.0 solved the problem.

I was using Rails 6.1.1 by the way.

Xenos answered 19/1, 2021 at 11:15 Comment(0)
B
0

In Gemfile : gem 'will_paginate', '~> 3.1' In other file : <%= will_paginate @articles%>

Bond answered 13/6, 2021 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.