Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble with will_paginate method

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

like image 442
Abhishek Sharma Avatar asked Apr 17 '19 10:04

Abhishek Sharma


3 Answers

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

like image 120
Michael Krøyserth-Simsø Avatar answered Nov 02 '22 01:11

Michael Krøyserth-Simsø


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

like image 5
Carlos Avatar answered Nov 02 '22 01:11

Carlos


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.

like image 3
EightT Avatar answered Nov 02 '22 01:11

EightT