Forum: Ruby on Rails will_paginate in multiple resources search

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.
115b8365425ebbde85b24375c698f83f?d=identicon&s=25 André Cardoso (belerophon87)
on 2009-01-30 01:38
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.
7e35ecb8cb04c4c15cf0ad1a0edf113d?d=identicon&s=25 anton effendi (Guest)
on 2009-01-30 03:48
(Received via mailing list)
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 <
rails-mailing-list@andreas-s.net> 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/.
>
> >
>


--
Wu You Duan
This topic is locked and can not be replied to.