Find with OR : Search « ActiveRecord « Ruby






Find with OR




Account.find :all, :conditions => [ "updated_on > ? OR id IN (?)",
                                    @last_update,
                                    [ 2, 3, 5, 7, 11 ] ]

It will result in the following SQL:

SELECT *
  FROM accounts
  WHERE
    updated_on > '20061214 15:29:12'
    OR id IN (2, 3, 5, 7, 11)

 








Related examples in the same category

1.Find by column name
2.Find by conditions
3.id is default for find(1)
4.A find_or_create_by_* dynamic finder
5.Find many values
6.Find first or find all
7.Find with conditions
8.Find with AND