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,
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
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,