How to find data by dynamic conditions on Rails? <p>I am using Rails 3.2.13 now.</p> <p>I made this method:</p> <pre><code>def search search_conditions = [] search_conditions &lt;&lt; ["id = ?", params[:id]] if params[:id] != '' search_conditions &lt;&lt; ["name LIKE ?", "%#{params[:name]}%"] if params[:name] != '' @users = User.find(:all, :conditions =&gt; search_conditions) end </code></pre> <p>But the result was:</p> <pre><code>undefined method `%' for ["name LIKE ?", "%tes%"]:Array </code></pre> <p>Can't I set multiple conditions in a nice way?</p>