Old Emmanuel Oga's Weblog (new one is at www.emmanueloga.com)

two very useful pieces of code related to will_paginate and acts_as_ferret

Posted in Uncategorized by emmanueloga on septiembre 28, 2007

Related to:

  • Paginating with will_paginate _and_ ajax
  • Paginating acts_as_ferret results

Lately, I’ve been developing an application with huge amounts of data. For this reason i couldn’t delay anymore the use of pagination on my views. I wanted to use will_paginate because it is such a nice plugin, but i was annoyed for it’s lack of support for ajax. The solution was quite simple, tough, because rails makes it so easy. I only had to change the link_to calls for link_to_remote calls. I was almost there when i decided to check the repository of will paginate. There, i found that a patch by Florent Piteau was already there resolving this very issue. So here you are:

http://err.lighthouseapp.com/projects/466/tickets/67-will-paginate-patch-ajax-support

or the complete source (just change view_helpers.rb for this one, or load this file on environment.rb):

http://pastie.caboo.se/101715

Also, there is a patch to paginate ferret search results that is really easy to use. Here you are:

http://opensoul.org/2007/8/17/acts_as_ferret-will_paginate
http://pastie.caboo.se/101716

Note: I added the

def final_pager.total_hits
total_entries()
end

bit to add compatibility with my previous api.

Una respuesta

Subscribe to comments with RSS.

  1. […] actually this is a little more improved […]


Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: