summaryrefslogtreecommitdiff
path: root/app/models/snippet.rb
diff options
context:
space:
mode:
authorNihad Abbasov <narkoz.2008@gmail.com>2012-09-26 23:20:36 -0700
committerNihad Abbasov <narkoz.2008@gmail.com>2012-09-27 02:05:53 -0700
commit841e4fbd08d2d642c127506001a76a973ea3d536 (patch)
tree56a894ecdf3978bc3032daa8fae294dad897018d /app/models/snippet.rb
parent2a4359a572c123d117988487f9bb29f4ae176ceb (diff)
downloadgitlab-ce-841e4fbd08d2d642c127506001a76a973ea3d536.tar.gz
cosmetical cleanup of models
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb25
1 files changed, 6 insertions, 19 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 10e376454b1..b37d6bef139 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -7,25 +7,12 @@ class Snippet < ActiveRecord::Base
belongs_to :author, class_name: "User"
has_many :notes, as: :noteable, dependent: :destroy
- delegate :name,
- :email,
- to: :author,
- prefix: true
+ delegate :name, :email, to: :author, prefix: true
- validates_presence_of :project_id
- validates_presence_of :author_id
-
- 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 }
+ validates_presence_of :author_id, :project_id
+ 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 }
scope :fresh, order("created_at DESC")
scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current])
@@ -59,6 +46,7 @@ class Snippet < ActiveRecord::Base
expires_at && expires_at < Time.current
end
end
+
# == Schema Information
#
# Table name: snippets
@@ -73,4 +61,3 @@ end
# file_name :string(255)
# expires_at :datetime
#
-