Will_paginate : problem with undefined method `total_pages


#1

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.


#2

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.


#3

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?