Reputation: 687
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
Upvotes: 10
Views: 4327
Reputation: 37
In Gemfile : gem 'will_paginate', '~> 3.1'
In other file : <%= will_paginate @articles%>
Upvotes: 0
Reputation: 73
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.
Upvotes: 4
Reputation: 5132
I had this problem and I browse some time to get the solution, the exact error that I got was :
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
Upvotes: 5
Reputation: 1044
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
Upvotes: 15