Is it possible to filter by conditions before paginating?

Posted by Brian Roisentul on Stack Overflow See other posts from Stack Overflow or by Brian Roisentul
Published on 2010-06-15T00:20:53Z Indexed on 2010/06/15 0:22 UTC
Read the original article Hit count: 472

I'm using ruby on rails 2.3.8 and will_paginate plugin.

I've just noticed that if I write something like this:

Announcement.paginate :page => params[:page], :per_page => 10, :conditions => some_condition

it will work.

But, if I write something like this:

announcements = Announcement.all :conditions => some_condition
@ann = announcements.paginate :page => params[:page], :per_page => 10

it won't recognize conditions.

Maybe you're wondering "why would he want to do that?", well, it's a long story and I really need to first filter the conditions and then paginate the results.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about will-paginate