Skip to content

Commit 8ef51a0

Browse files
committed
Ensure event cover images must be image file types
TODO: add validations to other profile, cover, and card images
1 parent 5773260 commit 8ef51a0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/models/better_together/event.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ class Event < ApplicationRecord
3737
saver: { strip: true, quality: 85, optimize_coding: true }, format: 'png'
3838
end
3939

40+
CONTENT_TYPES = %w[image/jpeg image/png image/gif image/webp image/svg+xml].freeze
41+
42+
validates :cover_image,
43+
content_type: CONTENT_TYPES,
44+
size: { less_than: 100.megabytes, message: 'is too large' }
45+
4046
alias card_image cover_image
4147

4248
attr_accessor :remove_cover_image

0 commit comments

Comments
 (0)