Rails 3.2 和 Ransack - 是否可以在 sort_link 中传递额外的参数? [英] Rails 3.2 and Ransack - Is it possible to pass additional params in a sort_link?

查看:49
本文介绍了Rails 3.2 和 Ransack - 是否可以在 sort_link 中传递额外的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一切都在标题中...

使用 rails 3.2.11 和 Ransack 一切正常...我添加了一个功能,让我的用户选择每页显示的项目数,它也工作正常,但是当我点击 sort_link 时,我失去了per_page"选项

Using rails 3.2.11 and Ransack all works fine... I added a functionality to let my users choose the number of items to show per page and it works fine too, but I lose the "per_page" choice when I click on the sort_link

因为我可以像这样将额外的参数传递给 will_paginate

As I can pass additional params to will_paginate like this

<%= will_paginate :params => {:pp => params[:pp]} %>

有没有办法用 Ransack sort_link 做同样的事情?

Is there a way to do the same thing with a Ransack sort_link ?

干杯

推荐答案

我找到了!

解决方案:

<th><%= sort_link(@q, :profile_last_name, 'Last name',{:pp => params[:pp]}) %></th>

干杯

这篇关于Rails 3.2 和 Ransack - 是否可以在 sort_link 中传递额外的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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