From 36ef94d763f7e8d7f63e5c56c455d8cab87075a6 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Thu, 21 Jul 2016 11:29:42 +0200 Subject: [PATCH] Prevent empty report reasons for screenshots --- app/models/screenshot.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/screenshot.rb b/app/models/screenshot.rb index d87028e..21f1a01 100644 --- a/app/models/screenshot.rb +++ b/app/models/screenshot.rb @@ -1,10 +1,6 @@ class Screenshot < ActiveRecord::Base belongs_to :package, :inverse_of=>:screenshots - # default_scope { - # order('created_at DESC') - # } - has_attached_file :image, styles: { :large => '800x600>', :thumb => '160x120>' }, default_url: '/images/dummy/no-screenshots-available.svg', @@ -13,6 +9,7 @@ class Screenshot < ActiveRecord::Base validates_attachment_content_type :image, :content_type => 'image/png' validates_with AttachmentSizeValidator, :attributes => :image, :less_than => 5.megabytes validate :validate_image_is_unique + validates :delete_reason, length: { in: 5..100 }, allow_nil: true # Validator that checks if the image has already been uploaded. # A generic uniqueness validator does not work because it would attribute