How to apply OR condition in model.find?

Hi,

@table_names = TableName.find(:all, :conditions=>{:column_name => params[:gm], :column_id => params[:id]})

Here, I used two conditions to find SQL. This two conditions applies with “AND”. I need to apply this two conditions with “OR” condition.

Applying “|” or "||"symbol fails… How I can apply OR condition, Kinldy help me.

Hi,

@table_names = TableName.find(:all, :conditions=>{:column_name =>
params[:gm], :column_id => params[:id]})

Here, I used two conditions to find SQL. This two conditions applies with
"AND". I need to apply this two conditions with "OR" condition.

Use the array form for conditions
@table_names = TableName.find(:all, :conditions=>[ 'column_name = ? OR
column_id = ?', params[:gm], params[:id] ])

Colin

Dear Collin…

Wooww… Excellent… Tanx @ extreme. I too tried with many examples obtained from online forums… This made me fun…