Multiple conditions with will_paginate
Posted
by user363243
on Stack Overflow
See other posts from Stack Overflow
or by user363243
Published on 2010-06-10T08:46:03Z
Indexed on
2010/06/10
9:02 UTC
Read the original article
Hit count: 193
ruby-on-rails
|will-paginate
I am using will_paginate for pagination but I can't seem to use more than one condition at a time. For example, if I want to have a sql query that ends in "Where office_id = 5", then it's pretty straight forward, I can do that. but what if I want to do "Where office_id = 5 AND primary_first = 'Mark'"? I can't do that. I have no idea how to enter multiple conditions. Can you help??
Below is an example of my code:
def self.search(search, page, office_id)
paginate :per_page => 5, :page => page,
:conditions => ['office_id', "%#{office_id}"], # + ' and primary_first like ?', "%#{params[:search]}%"],
#:conditions => ['primary_first', "%#{search}%"],
:order => 'created_at'
end
Thank you for your help!
© Stack Overflow or respective owner