Commit 8adf9c79 authored by Andrew8xx8's avatar Andrew8xx8

Additional scopes added

parent 770f262a
...@@ -30,9 +30,12 @@ class Snippet < ActiveRecord::Base ...@@ -30,9 +30,12 @@ class Snippet < ActiveRecord::Base
validates :content, presence: true validates :content, presence: true
# Scopes # Scopes
scope :public, -> { where(private: false) }
scope :private, -> { where(private: true) }
scope :fresh, -> { order("created_at DESC") } scope :fresh, -> { order("created_at DESC") }
scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } 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 def self.content_types
[ [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment