Ruby on Rails 3 howto make 'OR' condition

前端 未结 9 1401
無奈伤痛
無奈伤痛 2020-12-03 00:34

I need an SQL statement that check if one condition is satisfied:

SELECT * FROM my_table WHERE my_table.x=1 OR my_table.y=1

I want to do th

9条回答
  •  佛祖请我去吃肉
    2020-12-03 01:17

    You can define an Array as value in the :conditions Hash.

    So you could do for example:

    Account.all(:conditions => { :id => [1, 2] })
    

    Tested with Rails 3.1.0

提交回复
热议问题