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
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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With