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!

On Aug 1, 2008, at 1:37 PM, Justin To wrote:

‘tags AND body like ?’

Not sure what’s the proper syntax for this,

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!

Philip H. 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:

SQL Tutorial

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

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:

-philip