Forum: Ferret will_paginate : problem with undefined method `total_pages

Posted by John Small (johnsmall)
on 2008-10-13 08: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 Small
Posted by John Small (johnsmall)
on 2008-10-13 08: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 Small

John Small 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 Small
Posted by John Small (johnsmall)
on 2008-10-13 11: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 Small


John Small 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?
> 
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.