Find with conditions : Search « ActiveRecord « Ruby

Find with conditions

Account.find :all, :conditions => "keyword = 'ruby'"
Account.find :all, :conditions => { :keyword => 'ruby' }
Account.find :all, :conditions => [ "keyword = ?", 'ruby' ]

These statements will all generate the following WHERE clause:

SELECT * FROM accounts WHERE keyword = 'ruby'


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 AND
8.Find with OR