简体   繁体   English

需要关于act_as_ferret和will_paginate的帮助,以便一起玩

[英]need help with acts_as_ferret and will_paginate to play nice together

I have installed will_paginate and acts_as_ferret on my system for ruby rails. 我已经在系统上安装了ruby rails的will_paginate和acts_as_ferret。
My paginate seems to work fine before installing acts_as_ferret. 在安装acts_as_ferret之前,我的分页似乎工作正常。 When I put in the code to do searching I get the following error: 当我放入代码进行搜索时,出现以下错误:

NoMethodError in Community#search  

Showing app/views/community/_result_summary.rhtml where line #3 raised:  

undefined method `total_entries' for []:Array  

Extracted source (around line #3):  

1: <% if @users %>  
2: <p>  
3: Found <%= pluralize(@users.total_entries, "match") %>.  
4: </p>  
5: <% end %>  

If I take out the search function, paginate works but it's pointless because I can't do searches. 如果我取消了搜索功能,则分页可以工作,但没有意义,因为我无法进行搜索。 Can any one help me out on this one?? 有人可以帮我吗?

Thanks!! 谢谢!!

Stephen 史提芬

undefined method `total_entries' for []:Array []:Array的未定义方法`total_entries'

eror itself shows that you are calling total_entries method which is not array method. 错误本身表明您正在调用total_entries方法,而不是数组方法。 you get more than one user in your @users. 您的@users中有多个用户。 try 尝试

1: <% unless @users.blank? %>  
2: <p>  
3: Found <%= pluralize(@users[0].total_entries, "match") %>.  
4: </p>  
5: <% end %>  

EDITED TRY 编辑尝试

1: <% unless @users.blank? %>  
2: <p>  
3: Found <%= pluralize(@users.length, "match") %>.  
4: </p>  
5: <% end %>  

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

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