Additional scopes added
This commit is contained in:
parent
770f262a6a
commit
8adf9c7956
1 changed files with 5 additions and 2 deletions
|
@ -30,9 +30,12 @@ class Snippet < ActiveRecord::Base
|
|||
validates :content, presence: true
|
||||
|
||||
# Scopes
|
||||
scope :fresh, -> { order("created_at DESC") }
|
||||
scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
|
||||
scope :public, -> { where(private: false) }
|
||||
scope :private, -> { where(private: true) }
|
||||
scope :fresh, -> { order("created_at DESC") }
|
||||
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
|
||||
scope :has_project, -> { where("bars.id IS NOT NULL") }
|
||||
scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
|
||||
|
||||
def self.content_types
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue