paginate conditions

paginate :per_page => 15, :page => page,
:conditions => ['tags like ?', "%#{search}%"], :order => 'created_at
DESC'

Hi, just wondering how I would change the conditions to include an extra
like?

I want to do:
'tags AND body like ?'

Not sure what's the proper syntax for this,

Thanks!

That part is straight SQL (with some nice substitutions) so you'd want:

:conditions => ['tags LIKE ? AND body LIKE ?', "%#{search}%", "%#{search}%"]

that will return results where both tag and body are like your search.

-philip

Super, thanks! Is there such an operator as OR?

Thanks!

Super, thanks! Is there such an operator as OR?

Yep. OR :slight_smile:

No idea what your level of SQL knowledge is and I don't mean to give offense, but you may find this helpful:

http://w3schools.com/sql/default.asp

-philip

Philip Hallstrom wrote:

Super, thanks! Is there such an operator as OR?

Yep. OR :slight_smile:

No idea what your level of SQL knowledge is and I don't mean to give
offense, but you may find this helpful:

http://w3schools.com/sql/default.asp

-philip

Ha ha, thanks Philip. I've read that article before. The problem is, I
haven't worked very much with SQL at all before. =) Thanks!