Commit 8adf9c79560f0b1d39270b8ee957df75b53fc30a
1 parent
770f262a
Exists in
master
and in
4 other branches
Additional scopes added
Showing
1 changed file
with
5 additions
and
2 deletions
Show diff stats
app/models/snippet.rb
... | ... | @@ -30,9 +30,12 @@ class Snippet < ActiveRecord::Base |
30 | 30 | validates :content, presence: true |
31 | 31 | |
32 | 32 | # Scopes |
33 | - scope :fresh, -> { order("created_at DESC") } | |
34 | - scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) } | |
33 | + scope :public, -> { where(private: false) } | |
34 | + scope :private, -> { where(private: true) } | |
35 | + scope :fresh, -> { order("created_at DESC") } | |
35 | 36 | scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } |
37 | + scope :has_project, -> { where("bars.id IS NOT NULL") } | |
38 | + scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) } | |
36 | 39 | |
37 | 40 | def self.content_types |
38 | 41 | [ | ... | ... |