Find with AND : Search « ActiveRecord « Ruby

Find with AND

Account.find :all, :conditions => { :first_name =>  @first_name,
                                    :last_name => @last_name,
                                    :favorite_band_id => nil }

which would result in the following SQL query:

  FROM accounts
    first_name = 'John'
    AND last_name = 'Doe'
    AND favorite_band_id IS NULL


Related examples in the same category

1.Find by column name
2.Find by conditions 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 OR