Rails-按字母顺序的分页/导航 [英] Rails - Alphabetical Pagination/Navigation

查看:81
本文介绍了Rails-按字母顺序的分页/导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有Rails插件可以按字母顺序进行分页/导航吗?

Is there a rails plugin that will do alphabetical pagination/navigation?

我的数据集非常大,除了1..2 ... 3 ... 4 ... 5分页之外,我还希望它能为用户提供更直接的导航提示.

I have a very large data set and would prefer something that gave users a more direct navigation cue in addition to 1..2...3...4...5 pagination.

我可以自己编写代码,但想知道是否已经有一个像样的插件可以为我做到这一点.

I could code it myself but was wondering if there was a decent plugin out there already that would do it for me.

推荐答案

为什么不能将要查看其结果的字母作为参数传递?然后对结果进行分页?就是

Why can you not have the alphabet for which you want to see the results to, passed as a parameter? And then paginate on the results? That is,

# show results of params[:alphabet] alphabet
@results = fetch_results(params[:alphabet]) 
# Use Will Paginate to fetch results internally and give a condition that 
# fetches results starting with the passed alphabet.

并在视图上使用<%= will_paginate @results %>显示分页结果(编号).

And show paginated results (numbered) using <%= will_paginate @results %> on the view.

这篇关于Rails-按字母顺序的分页/导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆