# Multiple :conditions?

**URL:** <https://www.ruby-forum.com/t/multiple-conditions/95828>\
**Category:** Rails\
**Created:** [June 15, 2006, 6:43am UTC](https://www.ruby-forum.com/t/multiple-conditions/95828 "2006-06-15T06:43:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasbur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@jasbur](https://www.ruby-forum.com/u/jasbur)\
**Post date:** [June 15, 2006, 6:43am UTC](https://www.ruby-forum.com/t/multiple-conditions/95828/1 "2006-06-15T06:43:18Z")

</div>

How do I add multiple conditions to a paginated list? I have:

@post\_pages, @posts = paginate(:posts,  
:per\_page =\> 10,  
:conditions =\> [ ‘(title) OR (body)  
LIKE ?’, ‘%’ + params[:query] + ‘%’],  
:order =\> ‘end\_date’)

I would like to add a:

‘end\_date \>= NOW()’

to the mix. I can get it to work if it’s the only condition. But I can’t  
get both of them to play nice. I’m also getting a “cannot convert nil  
into String” exeption when I click on the “Next” link. View code below.

\<%= link\_to ‘Previous page’, { :page =\> @post\_pages.current.previous }  
if @post\_pages.current.previous %\>  
\<%= link\_to ‘Next page’, { :page =\> @post\_pages.current.next } if  
@post\_pages.current.next %\>

---

<div class="post-metadata">

**Author:** ![jasbur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@jasbur](https://www.ruby-forum.com/u/jasbur)\
**Post date:** [June 15, 2006, 10:13am UTC](https://www.ruby-forum.com/t/multiple-conditions/95828/2 "2006-06-15T10:13:13Z")

</div>

To pass more than one Ruby value to the condition, use a hash with  
individual symbol names for substituted values:

:conditions =\> [ ‘(title) OR (body) LIKE :my\_like AND end\_date =  
:my\_date’,  
{:my\_like =\> ‘%’ + params[:query] + ‘%’, :my\_date =\> Time.now} ]

Julian
