All scopes must be in lambdas

This commit is contained in:
Andrew8xx8 2013-02-12 11:16:45 +04:00
parent 9a22ac63ec
commit b5db541338
9 changed files with 22 additions and 22 deletions

View file

@ -31,9 +31,9 @@ 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 :expired, where(["expires_at IS NOT NULL AND expires_at < ?", Time.current])
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]) }
def self.content_types
[