开发者

need help with acts_as_ferret and will_paginate to play nice together

开发者 https://www.devze.com 2022-12-28 20:12 出处:网络
I have installed will_paginate and acts_as_ferret on my system for ruby rails. My paginate seems to work fine before installing acts_as_ferret.When I put in the code to do searching I get the 开发者_如

I have installed will_paginate and acts_as_ferret on my system for ruby rails.

My paginate seems to work fine before installing 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

eror itself shows that you are calling total_entries method which is not array method. you get more than one user in your @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 %>  
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号