Skip to content

Instantly share code, notes, and snippets.

@EricLondon
Created February 13, 2019 17:31
Show Gist options
  • Save EricLondon/f1443520a7bca139278f94e292ae1a01 to your computer and use it in GitHub Desktop.
Save EricLondon/f1443520a7bca139278f94e292ae1a01 to your computer and use it in GitHub Desktop.
Rails other/remaining scopes
# frozen_string_literal: true
class Color < ApplicationRecord
scope :red, -> { where(color: 'red') }
scope :yellow, -> { where(color: 'yellow') }
scope :blue, -> { where(color: 'blue') }
scope :non_primary, -> { where.not(id: red).where.not(id: yellow).where.not(id: blue) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment