[#347] small validation refactoring
This commit is contained in:
parent
15cbc93154
commit
8fb07626aa
|
@ -10,7 +10,7 @@ class Avatar < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
has_attached_file :avatar, styles: AVATAR_SIZES_HASH
|
||||
validates_inclusion_of :avatar_file_size, in: (0..MAX_AVATAR_SIZE), allow_nil: true
|
||||
validates_attachment_size :avatar, less_than_or_equal_to: MAX_AVATAR_SIZE
|
||||
validates_attachment_content_type :avatar, content_type: /\Aimage/
|
||||
validates_attachment_file_name :avatar, matches: [ /(png|jpe?g|gif|bmp|tif?f)\z/i ]
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Modules
|
|||
included do
|
||||
has_attached_file :srpm
|
||||
|
||||
validates_attachment :srpm, size: { in: 0..500.megabytes }
|
||||
validates_attachment_size :srpm, less_than_or_equal_to: 500.megabytes
|
||||
validates_attachment_content_type :srpm, content_type: ['application/octet-stream', "application/x-rpm", "application/x-redhat-package-manager"], message: I18n.t('layout.invalid_content_type')
|
||||
|
||||
after_create :create_git_repo
|
||||
|
|
Loading…
Reference in New Issue