diff options
author | Andrew8xx8 <avk@8xx8.ru> | 2013-03-25 00:23:12 +0400 |
---|---|---|
committer | Andrew8xx8 <avk@8xx8.ru> | 2013-03-25 00:23:12 +0400 |
commit | 8adf9c79560f0b1d39270b8ee957df75b53fc30a (patch) | |
tree | 6dae6b79a0df1145461c0c0e622e509dd8ec8440 /app | |
parent | 770f262a6a89ff5335ed452b83d1b8edb3e3ff5d (diff) | |
download | gitlab-ce-8adf9c79560f0b1d39270b8ee957df75b53fc30a.tar.gz |
Additional scopes added
Diffstat (limited to 'app')
-rw-r--r-- | app/models/snippet.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 7018dc67ab7..1d454801315 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -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 [ |