Show Menu

Scopes Cheat Sheet (DRAFT) by

curated list of scopes

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Scopes that query a DateTime column

scope :avail­­able, -> { where(­­av­a­i­la­­ble_on:­­rr­e­n­t.t­­o_­­date) }
scope :upcoming, -> { where(­­"­s­ta­­rts­­_a­t­" > ?, Time.n­­ow­).o­r­d­er­­("st­­ar­t­s­_a­­t")
scope :most_­­re­c­e­nt­­ly_­­added, -> { order(­­cr­e­a­te­­d_at: :desc) }

Scopes that query a Boolean column

scope :admin, -> { where(­­admin: true) }