- User.where(:email => nil)
- User Load (15.2ms) SELECT * FROM users WHERE (users.email IS NULL)
- The hash notation is smart enough to create an IN clause if you associate an array of values with a particular key.
- Product.where(:sku => [9400,9500,9900])
- Message.where(“subject LIKE :foo OR body LIKE :foo”, :foo => ‘%woah%’)
- In other words, when you’re using named placeholders (versus question mark characters) you can use the same bind variable more than once. Like, whoa!
- A clever, performant, and portable way to get a random record is to generate a random offset in Ruby.
- Timsheet.limit(1).offset(rand(Timesheet.count)).first