Hi you all, I have an app where I do two "finds" in different tables: @results_m = Man.find(:all) @results_w = Woman.find(:all) I can paginate each of one with paginate: @results_m = Man.paginate([params page stuff here...]) @results_w = Woman.paginate([params page stuff here...]) However, I want to show the two kinds of results in the same view and with the pagination as if they were only from a single type of resource. Can will_paginate do the trick somehow? (maybe something like @results @results_m + @results_w, which of course also sums the total records in Man table and Woman table). Or should I do it manually? -- Posted via http://www.ruby-forum.com/.
> On Jul 15, 1:59 pm, Damaris Fuentes <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > Hi you all, I have an app where I do two "finds" in different tables: > > @results_m = Man.find(:all) > @results_w = Woman.find(:all) > > I can paginate each of one with paginate: > @results_m = Man.paginate([params page stuff here...]) > @results_w = Woman.paginate([params page stuff here...]) > > However, I want to show the two kinds of results in the same view and > with the pagination as if they were only from a single type of resource. > Can will_paginate do the trick somehow? (maybe something like @results > @results_m + @results_w, which of course also sums the total records in > Man table and Woman table). Or should I do it manually? > -- > Posted viahttp://www.ruby-forum.com/.Are you looking for single table inheritance?
Ummm.... not exactly. I have an app consisting on database federation, so basically I have to get the results of one table, get the results of other one, and merge them. The problem is that if I paginate the first result I get, let''s say, 10 records, then I paginate the second and I get 10 records, so the resulting one is 20 records size, not 10. I can paginate also this last one set of 20 results, but I would lost the total_pages of the original two first results. Apart from that, the gem should manage which table and with which limit and offset to ask when I do a request such as http://..../whatever?page=x So I''m afraid I shall do it manually somehow. Don''t think any paginating gem/plugin have a solution to this. pharrington wrote:>> However, I want to show the two kinds of results in the same view and >> with the pagination as if they were only from a single type of resource. >> Can will_paginate do the trick somehow? (maybe something like @results >> @results_m + @results_w, which of course also sums the total records in >> Man table and Woman table). Or should I do it manually? >> -- >> Posted viahttp://www.ruby-forum.com/. > > Are you looking for single table inheritance?-- Posted via http://www.ruby-forum.com/.