# Will\_paginate in multiple resources search

**URL:** <https://www.ruby-forum.com/t/will-paginate-in-multiple-resources-search/158988>\
**Category:** Rails\
**Created:** [January 30, 2009, 1:38am UTC](https://www.ruby-forum.com/t/will-paginate-in-multiple-resources-search/158988 "2009-01-30T01:38:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@andre](https://www.ruby-forum.com/u/andre)\
**Post date:** [January 30, 2009, 1:38am UTC](https://www.ruby-forum.com/t/will-paginate-in-multiple-resources-search/158988/1 "2009-01-30T01:38:35Z")

</div>

Hi. I need help 🙂

The thing is that I must write a controller to do a generic search  
throughout multiple resources available in an application.

So the idea was to do this:

1Âº – do all the searches  
@a = search1  
@b = search2  
@c = search3  
…

2Âº merge the results  
@result = @a + @b + @c + …

3Âº paginate the result … ???

I don’t know how to do the third step.

Also, I’m using a search library for fulltext search. And I dont want to  
loose that functionality. Also important, is that the result from each  
search is a paginated (using will\_paginate) array, automatically  
returned by the search library. So, @a, @b and @c are already limited  
results.

What I want is to mix them together, without loosing will\_paginate  
functionality.

So is it possible to do a thing like @a + @b + @c, and use will\_paginate  
to paginate the results again?

Please keep in mind that I’m not (obviously) an expert in ruby nor in  
rails.

Thank you.

---

<div class="post-metadata">

**Author:** ![andre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@andre](https://www.ruby-forum.com/u/andre)\
**Post date:** [January 30, 2009, 3:48am UTC](https://www.ruby-forum.com/t/will-paginate-in-multiple-resources-search/158988/2 "2009-01-30T03:48:02Z")

</div>

try…  
@result = @a + @b + @c + …  
@result = @result.paginate(…)

May be it will help you… if no help u, can you give a example… ?

Thank you

On Fri, Jan 30, 2009 at 7:38 AM, AndrÃ© Cardoso \<  
removed\_email\_address@domain.invalid\> wrote:

> @b = search2
> 
> to paginate the results again?
> 
> Please keep in mind that I’m not (obviously) an expert in ruby nor in  
> rails.
> 
> ## Thank you.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Wu You Duan
