gitlab-org--gitlab-foss/app/models/appearance.rb
Rémy Coutable e531a0c11c
Use the new CacheableAttributes concern in the ApplicationSetting and Appearance models
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-05-23 16:14:43 +02:00

28 lines
770 B
Ruby

class Appearance < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField
include ObjectStorage::BackgroundMove
include WithUploads
cache_markdown_field :description
cache_markdown_field :new_project_guidelines
validates :logo, file_size: { maximum: 1.megabyte }
validates :header_logo, file_size: { maximum: 1.megabyte }
validate :single_appearance_row, on: :create
mount_uploader :logo, AttachmentUploader
mount_uploader :header_logo, AttachmentUploader
# Overrides CacheableAttributes.current_without_cache
def self.current_without_cache
first
end
def single_appearance_row
if self.class.any?
errors.add(:single_appearance_row, 'Only 1 appearances row can exist')
end
end
end