Skip to content

Instantly share code, notes, and snippets.

User.pick(:name)
# SELECT "users"."name" FROM "users" LIMIT ? [["LIMIT", 1]]
# => "David"
User.where(id: 5).pick(:name, :city)
# SELECT "users"."name", "users"."city" FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 5], ["LIMIT", 1]]
# => ["Naiya", "Goa"]
class Feed < ActiveRecord::Base
enum status: %i[ active pending trashed ]
end
Feed.not_active # => where.not(status: :active)
Feed.not_pending # => where.not(status: :pending)
Feed.not_trashed # => where.not(status: :trashed)
class Claim < ActiveRecord::Base
self.implicit_order_column = :created_at
end