简体   繁体   English

Will_paginate 不渲染 Ruby On Rails

[英]Will_paginate not rendering Ruby On Rails

I have Will_Paginate installed on my app, and everything was working fine when suddenly i noticed that the link to the next pages were not showing up.我在我的应用程序上安装了 Will_Paginate,当我突然注意到下一页的链接没有显示时,一切正常。 Everything seems to be working fine other than that, no error messages or anything.除此之外,一切似乎都工作正常,没有错误消息或任何东西。 using will_paginate v 3.0.7使用 will_paginate v 3.0.7

here is my controller code这是我的 controller 代码

@apps = App.all.paginate(:page => params[:page], :per_page => 4).order(created_at: :desc)

here is my views这是我的观点

<%= will_paginate @apps, renderer: BootstrapPagination::Rails %>

Using will_paginate-bootstrap 1.0.1使用 will_paginate-bootstrap 1.0.1

in the HTML, there is simply nothing where the links should be rendered.在 HTML 中,根本没有应该呈现链接的地方。

I've gone through every single troubleshooting step, and everything seems to be working perfectly, except the links are not showing up.我已经完成了每一个故障排除步骤,一切似乎都运行良好,只是链接没有显示出来。

manually going to?page=2 works, but I can't seem to get the buttons to show up.手动转到?page=2 有效,但我似乎无法显示按钮。

Also for others in the future, make sure you have enough posts to require a second page.同样对于将来的其他人,请确保您有足够的帖子需要第二页。 If you do not have enough posts, then paginate will not render.如果您没有足够的帖子,则分页将不会呈现。

This can be fixed by adding more posts, or lower the per_page requirement, below your total number of posts.这可以通过添加更多帖子或将每页要求降低到帖子总数以下来解决。

Hopefully after 5 months you've solved this but in case someone else ends up with the same problem with will_paginate it does the .all work for you so your query can look like this: 希望在5个月后您已经解决了这个问题,但是如果其他人也遇到了will_paginate的相同问题,它将为您完成.all的工作,因此您的查询可以如下所示:

@apps = App.paginate(:page => params[:page], :per_page => 4).order(created_at: :desc)

and above your table on your page views like this: 在表格上方的表格上方,如下所示:

<%= will_paginate @apps %>

I ran into a few issues when trying to set it up, I'm pretty new to the gem as well... 尝试设置时遇到了一些问题,我对宝石也很陌生...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM