will_paginate:如何构建“下一页”链接?

我知道这一定非常简单,但环顾四周后我找不到答案。

我正在使用will_paginate插件,我喜欢有一个简单的“下一页”链接,而不是整个will_paginate链接集合。

我怎样才能做到这一点?

谢谢!

这将为您提供一个简单的下一个按钮。

protected # Tells WP how to render the "Next Page" link def next_page # The only difference from the default here is we renamed the link to "More" # and added a custom class, twitter_pagination previous_or_next_page(@collection.next_page, "Next", 'twitter_pagination') if @collection.next_page end # Remove all links except our :next_page def pagination [ :next_page ] end 

让我们知道您的身体情况如何。 这是一篇很棒的博客文章,你也应该阅读。 让我们知道您的身体情况如何。 祝一切顺利。

它实际上比你想象的要多得多,有些人可能称之为“Rails Way”。 http://thewebfellas.com/blog/2008/8/3/roll-your-own-pagination-links-with-will_paginate

但是你也可以做一个帮手,并使用方法current_pagetotal_pages 。 所以类似于:

 <% if @post.current_page < @post.total_pages %> <%= link_to "Next", "#{posts_path(@post)}?page=#{@post.current_page+1}" %> <% end %> 

在Rails v4上使用will_paginate v3:

 <%= will_paginate @posts, :page_links=>false %>