diff options
author | Valeriy Sizov <vsv2711@gmail.com> | 2012-10-09 01:17:38 -0700 |
---|---|---|
committer | Valeriy Sizov <vsv2711@gmail.com> | 2012-10-09 01:17:38 -0700 |
commit | dc33f71b181d154c8d9937f777fa16e9cf1d968d (patch) | |
tree | 1424eedeeeb4a9016d0f6dc5a5986c17e74e9122 /app/models/snippet.rb | |
parent | c348284fedb487474626b3dae9be73311f8382df (diff) | |
parent | a4cd738686659314f0bb9fd13a80845dc2b036ab (diff) | |
download | gitlab-ce-dc33f71b181d154c8d9937f777fa16e9cf1d968d.tar.gz |
Merge pull request #1656 from zzet/refactoring
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]) |