Updated heroku stack and now having will_paginate error

87 Views Asked by At

So I updated my heroku stack on my web app and am using ruby 3.2.2 with will_paginate 4.0, but am now receiving an error on one of my pagination pages. The specific error I'm getting is

2023-06-15T00:33:11.759517+00:00 app[web.1]: Rendered users/index.html.erb within layouts/application (Duration: 2.6ms | Allocations: 1025)
2023-06-15T00:33:11.759543+00:00 app[web.1]: Rendered layout layouts/application.html.erb (Duration: 2.7ms | Allocations: 1069)
2023-06-15T00:33:11.759701+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms (ActiveRecord: 2.5ms | Allocations: 2352)
2023-06-15T00:33:11.760282+00:00 app[web.1]: 
2023-06-15T00:33:11.760282+00:00 app[web.1]: ActionView::Template::Error (wrong number of arguments (given 4, expected 3)):
2023-06-15T00:33:11.760282+00:00 app[web.1]: 13:   <h3><%= link_to "Create New Dude", new_user_path %></h3>
2023-06-15T00:33:11.760283+00:00 app[web.1]: 14: <% end %>
2023-06-15T00:33:11.760283+00:00 app[web.1]: 15:
2023-06-15T00:33:11.760284+00:00 app[web.1]: 16: <%= will_paginate %>
2023-06-15T00:33:11.760284+00:00 app[web.1]: 17:
2023-06-15T00:33:11.760284+00:00 app[web.1]: 18: <table>
2023-06-15T00:33:11.760284+00:00 app[web.1]: 19:   <thead>
2023-06-15T00:33:11.760284+00:00 app[web.1]: 
2023-06-15T00:33:11.760285+00:00 app[web.1]: app/views/users/index.html.erb:16

With the actual code being

<%= will_paginate %>

<table>
  <thead>
    <th></th> <!-- Icon -->
    ... a bunch of stuff you don't need to see ...
  </thead>
  <tbody>
    <%= render @users %>
  </tbody>
</table>

<%= will_paginate %>

I can't find any clear documentation on will_paginate 4.0 on why this would be throwing that specific error of wrong number of arguments (given 4, expected 3). The only thing I can find is the new basic will_paginate use here https://github.com/mislav/will_paginate. Do I need to somehow bundle my table that I used to paginate into a new structure?

Any help would be greatly appreciated.

1

There are 1 best solutions below

0
borisano On

The new version of will_paginate no longer takes an options hash as its third argument. Instead, all of the options should be passed as keyword arguments. So, your code should be changed to:

<%= will_paginate @users, per_page: 10 %>

<table>
  <thead>
    <th></th> <!-- Icon -->
    ... a bunch of stuff you don't need to see ...
  </thead>
  <tbody>
    <%= render @users %>
  </tbody>
</table>

<%= will_paginate @users, per_page: 10 %>

The per_page option is used to specify how many records should be displayed per page. In this case, we are setting it to 10.

You can also pass other options to will_paginate as keyword arguments. For example, you could pass the renderer option to specify a custom pagination renderer.