diff options
author | Andrey Kumanyaev <me@zzet.org> | 2012-10-09 04:10:04 +0400 |
---|---|---|
committer | Andrey Kumanyaev <me@zzet.org> | 2012-10-09 04:10:04 +0400 |
commit | df7c52489a890ac38491682b4a3399beb7cdbc86 (patch) | |
tree | 9a81bee70285ac1e5a0c158eab5f4c981e49b86d /app/models/snippet.rb | |
parent | a635b9da97b0e104b8ac1a846344ec8a4abd3123 (diff) | |
download | gitlab-ce-df7c52489a890ac38491682b4a3399beb7cdbc86.tar.gz |
simple refactoring
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r-- | app/models/snippet.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb index b37d6bef139..e8670cdbcf2 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -9,11 +9,13 @@ class Snippet < ActiveRecord::Base delegate :name, :email, to: :author, prefix: true - validates_presence_of :author_id, :project_id + validates :author, presence: true + validates :project, presence: true validates :title, presence: true, length: { within: 0..255 } validates :file_name, presence: true, length: { within: 0..255 } validates :content, presence: true, length: { within: 0..10000 } + # 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]) |