简体   繁体   English

Rails中的will_paginate错误

[英]will_paginate error in rails

Excuse me I have a problem with will_paginate plugin. 请问,will_paginate插件有问题。

In localhost, in my controller, I use person.operations.descend_by_date.paginate :page => params[:page] || 1 在localhost中,在我的控制器中,我使用person.operations.descend_by_date.paginate :page => params[:page] || 1 person.operations.descend_by_date.paginate :page => params[:page] || 1 . person.operations.descend_by_date.paginate :page => params[:page] || 1 However in production the method show error. 但是在生产中该方法显示错误。 I think that the problem is thye parameter page. 我认为问题出在您的参数页面。 Because person.operation.descend_by_date return a collection i try passing only params[:page] || 1 因为person.operation.descend_by_date返回一个集合,所以我尝试passing only params[:page] || 1 passing only params[:page] || 1 . passing only params[:page] || 1

However in localhost show error. 但是在本地主机显示错误。 The rare subject is: 罕见的主题是:

If I evaluate the method once => Show error IF i evaluate the method twice or more times => works ok 如果我评估方法一次=>如果我评估方法两次或多次,则显示错误=>可以

Rails show this message error: hash parameters expected Rails显示此消息错误: hash parameters expected

Why could be the error? 为什么会出现错误?

First i convert the will_paginate object to array and then i use the method for arrays of will_paginate 首先,我将will_paginate对象转换为array,然后将方法用于will_paginate的数组

person.operations.descend_by_date.to_a.paginate params[:page] || 1

Thanks 谢谢

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

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