Skip to content

Instantly share code, notes, and snippets.

@dombarnes
Created July 10, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dombarnes/057413b82c104ccbc1d9 to your computer and use it in GitHub Desktop.
Save dombarnes/057413b82c104ccbc1d9 to your computer and use it in GitHub Desktop.
Named scopes
scope :recent, -> { order('created_at DESC') }
scope :owned, -> { where('user_id = ?', 'current_user.id' ) }
scope :current_user_only, -> { where('user_id = ?', 'current_user.id') }
scope :pending_items, -> { where(:quote_status => 'Pending') }
scope :lost_items, -> { where(:quote_status => 'Lost')}
scope :won_items, -> { where(:quote_status => 'Won')}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment