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.


With Regards
Palani Kannan. K
Office: +49-531-2616-226
Mobile: +4917647098166

On 9 September 2010 12:32, PalaniKannan K [email protected]
wrote:

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…

On 9 September 2010 14:43, Colin L. [email protected] wrote:

@table_names = TableName.find(:all, :conditions=>[ 'column_name = ? OR


[email protected][email protected]
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


With Regards
Palani Kannan. K
Office: +49-531-2616-226
Mobile: +4917647098166

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs