Forum: Ruby on Rails Pagination and Parent Conditions

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Brent J. (Guest)
on 2006-04-04 23:44
(Received via mailing list)
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


- Brent
Paul B. (Guest)
on 2006-04-04 23:51
(Received via mailing list)
I would assume this can be done using a combination of the :conditions
:joins options of the paginate method
Brent J. (Guest)
on 2006-04-05 00:12
(Received via mailing list)
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).


- Brent
This topic is locked and can not be replied to.