items = Model .where(first_name: 'Harvey') .where('id = 3') .where('id = ?', 3) .order(:title) .order(title: :desc) .order("title DESC") .reorder(:title) # discards other .order's .rewhere(...) # discards other .where's .limit(2) .offset(1) .uniq See: QueryMethods items = Model .select(:id) .select([:id, :name]) .group(:name) # GROUP BY name .group('name AS grouped_name, age') .having('SUM(price)
![Rails models cheatsheet](https://cdn-ak-scissors.b.st-hatena.com/image/square/094c8fc34c2835d38796028b1f6f8fdb3bf4729b/height=288;version=1;width=512/https%3A%2F%2Fassets.devhints.io%2Fpreviews%2Frails-models.jpg)