Searching multiple fields with conditions

I am very new at RoR but am trying to tweak the code for the AJAX table from http://dev.nozav.org/rails_ajax_table.html.

I have it all working the way I want except for one line of code:

conditions = ["firstname LIKE ?" , "%#{@params[:query]}%"] unless @params[:query].nil?

I need this to look at multiple fields not just firstname. Any idea how I do this?

unless params[:query].blank?    query = "%#{@params[:query]}%"    conditions = ["firstname LIKE ? OR lastname LIKE ?", query, query] end

You can add as many OR's as you want as long as you keep adding more query's to the end.

Your database may not like you if you do this, but that's another matter :slight_smile:

-philip