[英]How to change a parameter in kaminari pagination - Ruby On Rails
My pagination works like;我的分页工作如下;
/questions/meals/fish?page=1
I would like to modify the second parameter of this URL like:我想修改这个 URL 的第二个参数,如:
/questions/deserts/fish?page=1
How can I change the second parameter?如何更改第二个参数? (preferably without modifying the
routes.rb
file) (最好不修改
routes.rb
文件)
In the kaminari paginate
helper method you can override the controller and action在 kaminari
paginate
helper 方法中,您可以覆盖控制器和操作
paginate @users, params: {controller: 'foo', action: 'bar'}
So in your case...所以在你的情况下...
paginate @fishes, params: {controller: 'desserts', action: 'fish'}
Note that it has to be a valid route in your routes.rb
or when the link is clicked, the app won't accept the path.请注意,它必须是
routes.rb
的有效路径,否则单击链接时,应用程序将不接受该路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.