Can I do any "fancy" conditionals when using the Pagination helper? The problem is that I want to be able to specify a conditional based on the criteria of a parent object. Here''s an example: Object A has_many Object B''s I want to paginate through 100 B''s but I *only* want it to return the ones who''s A.flag = true I poked around through the Wiki and list archive but didn''t see anything. Thanks, - Brent
I would assume this can be done using a combination of the :conditions and :joins options of the paginate method http://api.rubyonrails.org/classes/ActionController/Pagination.html#M000103 On 4/4/06, Brent Johnson <bljohnson@gmail.com> wrote:> > Can I do any "fancy" conditionals when using the Pagination helper? > The problem is that I want to be able to specify a conditional based > on the criteria of a parent object. Here''s an example: > > Object A has_many Object B''s > > I want to paginate through 100 B''s but I *only* want it to return the > ones who''s A.flag = true > > I poked around through the Wiki and list archive but didn''t see anything. > > Thanks, > > - Brent > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060404/3bcc9033/attachment.html
Wow, I looked directly at the pagination page and I missed the :joins option. I did manage to find a workaround, but it''s not near as clean as using the :joins option. I found a method called paginate_collection, so I pulled and filtered the results and called that instead of the pagination helper. Using the join will work much better (especially as the tables grow). Thanks, - Brent On 4/4/06, Paul Barry <mail@paulbarry.com> wrote:> I would assume this can be done using a combination of the :conditions and > :joins options of the paginate method > > http://api.rubyonrails.org/classes/ActionController/Pagination.html#M000103