所以我在我的web应用程序上更新了heroku堆栈,并使用了ruby 3.2.2和will_paginate 4.0,但现在我的一个分页页面上收到了一个错误。我得到的具体错误是
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
实际代码是
<%= 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 %>
我找不到任何关于will_paginate 4.0的清晰文档,说明为什么会抛出wrong number of arguments (given 4, expected 3)
的特定错误。我唯一能找到的是新的基本will_paginate用法https://github.com/mislav/will_paginate。我是否需要以某种方式将我曾经分页的表捆绑到一个新的结构中?
任何帮助将不胜感激。
1条答案
按热度按时间w6mmgewl1#
新版本的
will_paginate
不再将选项哈希作为其第三个参数。相反,所有选项都应该作为关键字参数传递。因此,您的代码应该更改为:per_page
选项用于指定每页应显示多少条记录。在这种情况下,我们将其设置为10。您还可以将其他选项作为关键字参数传递给
will_paginate
。例如,您可以传递renderer
选项来指定自定义分页呈现器。