# Will\_paginate : problem with undefined method \`total\_pages

**URL:** <https://www.ruby-forum.com/t/will-paginate-problem-with-undefined-method-total-pages/150776>\
**Category:** Ferret\
**Created:** [October 13, 2008, 8:00am UTC](https://www.ruby-forum.com/t/will-paginate-problem-with-undefined-method-total-pages/150776 "2008-10-13T08:00:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [October 13, 2008, 8:00am UTC](https://www.ruby-forum.com/t/will-paginate-problem-with-undefined-method-total-pages/150776/1 "2008-10-13T08:00:03Z")

</div>

Using  
Rails 2.1  
mislav-will\_paginate 2.3.4  
acts\_as\_ferret 0.4.3

Everything works fine except if I have this in my view

 \<%= page\_entries\_info @listitems %\> which works for a normal find or paginate\_by\_sql but doesn't work if I find\_with\_ferret since the returned entry array doesn't have the method 'total\_pages' in it.

Any idea how to get aaf to co-operate with mwp in this area?

Thanks

John S.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [October 13, 2008, 8:53am UTC](https://www.ruby-forum.com/t/will-paginate-problem-with-undefined-method-total-pages/150776/2 "2008-10-13T08:53:42Z")

</div>

OK, I’ve nearly answered my own question. aaf 0.4.3 conforms to the  
older version of will\_paginate which used ‘page\_count’ while the new  
version uses ‘total\_pages’. There’s a fix for this in aaf trunk with  
ticket number 216 1-MAY-2008, but this hasn’t made it into the released  
gem yet.

I could get the bleeding edge version, but that’s not available as a gem  
only as a plugin. I could just edit the code, it’s only a few lines, but  
then that becomes a nuisance when I have to install it on another  
machine because I have to remember to edit the gem again.

When can this change be pushed into the gem?

Thanks

John S.

John S. wrote:

> Using  
> Rails 2.1  
> mislav-will\_paginate 2.3.4  
> acts\_as\_ferret 0.4.3
> 
> Everything works fine except if I have this in my view
> 
> \<%= page\_entries\_info @listitems %\> which works for a normal find or paginate\_by\_sql but doesn't work if I find\_with\_ferret since the returned entry array doesn't have the method 'total\_pages' in it.
> 
> Any idea how to get aaf to co-operate with mwp in this area?
> 
> Thanks
> 
> John S.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [October 13, 2008, 11:45am UTC](https://www.ruby-forum.com/t/will-paginate-problem-with-undefined-method-total-pages/150776/3 "2008-10-13T11:45:17Z")

</div>

Ok, I’m much closer to answering my own question, because I’ve now got a  
workaround. Just add a file in your initializers directory that reopens  
ActsAsFerret::SearchResults and adds a new method

e.g. initializers/acts\_as\_ferret\_temporary\_patch.rb

class ActsAsFerret::SearchResults  
def total\_pages  
@total\_pages  
end  
end

It now works just fine.

I await the new gem so I can remove this file. Any idea when I’ll be  
able to type “sudo gem update acts\_as\_ferret” and then remove the patch?

Thanks

John S.

John S. wrote:

> OK, I’ve nearly answered my own question. aaf 0.4.3 conforms to the  
> older version of will\_paginate which used ‘page\_count’ while the new  
> version uses ‘total\_pages’. There’s a fix for this in aaf trunk with  
> ticket number 216 1-MAY-2008, but this hasn’t made it into the released  
> gem yet.
> 
> I could get the bleeding edge version, but that’s not available as a gem  
> only as a plugin. I could just edit the code, it’s only a few lines, but  
> then that becomes a nuisance when I have to install it on another  
> machine because I have to remember to edit the gem again.
> 
> When can this change be pushed into the gem?
