Forum: Ferret will_paginate : problem with undefined method `total_pages

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
John S. (Guest)
on 2008-10-13 10:00
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

 <span class="page_info">
        <%= page_entries_info  @listitems %>
      </span>
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.
John S. (Guest)
on 2008-10-13 10:53
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
>
>  <span class="page_info">
>         <%= page_entries_info  @listitems %>
>       </span>
> 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.
John S. (Guest)
on 2008-10-13 13:45
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?
>
This topic is locked and can not be replied to.