move cover image stuff to its own concern and add processing
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
class Group < ApplicationRecord
|
||||
include Paginable
|
||||
include GroupInteractions
|
||||
include GroupCoverImage
|
||||
|
||||
PER_ACCOUNT_LIMIT = 50
|
||||
|
||||
@@ -34,14 +35,6 @@ class Group < ApplicationRecord
|
||||
validates :title, presence: true
|
||||
validates :description, presence: true
|
||||
|
||||
LIMIT = 4.megabytes
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
|
||||
has_attached_file :cover_image
|
||||
validates_attachment_content_type :cover_image, content_type: IMAGE_MIME_TYPES
|
||||
validates_attachment_size :cover_image, less_than: LIMIT
|
||||
remotable_attachment :cover_image, LIMIT
|
||||
|
||||
validates_each :account_id, on: :create do |record, _attr, value|
|
||||
record.errors.add(:base, I18n.t('groups.errors.limit')) if Group.where(account_id: value).count >= PER_ACCOUNT_LIMIT
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user