Will_paginate

hi at all
I installed the plugin will_paginate successfully and now I’ll use it.
But I’ve a problem. I wrote a method search and this method return an
array of products. The search method is special and not an easy find
query. So I can use the :conditions of the will_paginate plugin. But I
will paginate the array of products.

So how I can use the will_paginate plugin to group the products
(:per_page => 5 products).

thanks for helping…

But I’ve the problem, that I use acts_as_ferret for fulltext search. So
I can’t use the :conditions statement in the paginate method. Because I
have for example a query like ‘search ruby’. So i want to find records
for ‘search ruby’, ‘search’ and ‘ruby’. So I call the find_by_content
method from ferret three times. So I think, the paginate method is
impractical, because I have the total_hits as recently as after the
three method calls.

Jesus bernardo Ruiz flores
wrote:http://www.ruby-forum.com/topic/147149?reply_to=650959#postform
will_paginate - Ruby Forum

Here is an example of how i use will_paginate to list 20 calls from page
and to change the conditions based on the restriction the user whan to
give:

def self.search(code,search,page)
if code.blank?
code=“DLXACCN”
end
paginate :per_page=>20, :page => page,
:conditions =>["#{code.upcase} like ?","%#{search}%"],
:order => “DLXDAT desc”
end

Code is the field that the user whan to check
search the value that the user is looking
page is the page number

And the controller look like this

def current_calls
@dlxcurrent_calls=DlxvcurrentCallsExt1.search(params[:code],params[:search],params[:page])
@sub_title=“Detalle Llamadas Actuales”
@pagetitle=“Monitoreo Clientes VoIP”
respond_to do |format|
format.html
format.xml {render :xml => @dlxcurrent_calls}
end
end

Hope this help

K. R. wrote:

hi at all
I installed the plugin will_paginate successfully and now I’ll use it.
But I’ve a problem. I wrote a method search and this method return an
array of products. The search method is special and not an easy find
query. So I can use the :conditions of the will_paginate plugin. But I
will paginate the array of products.

So how I can use the will_paginate plugin to group the products
(:per_page => 5 products).

thanks for helping…

Here is an example of how i use will_paginate to list 20 calls from page
and to change the conditions based on the restriction the user whan to
give:

def self.search(code,search,page)
if code.blank?
code=“DLXACCN”
end
paginate :per_page=>20, :page => page,
:conditions =>["#{code.upcase} like ?","%#{search}%"],
:order => “DLXDAT desc”
end

Code is the field that the user whan to check
search the value that the user is looking
page is the page number

And the controller look like this

def current_calls
@dlxcurrent_calls=DlxvcurrentCallsExt1.search(params[:code],params[:search],params[:page])
@sub_title=“Detalle Llamadas Actuales”
@pagetitle=“Monitoreo Clientes VoIP”
respond_to do |format|
format.html
format.xml {render :xml => @dlxcurrent_calls}
end
end

Hope this help

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs