Skip to content

Commit

Permalink
image/jpgのcontent_typeを削除した
Browse files Browse the repository at this point in the history
invalidなので。
  • Loading branch information
komagata committed Mar 6, 2025
1 parent b9e8486 commit b7a9870
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Article < ApplicationRecord
validates :thumbnail_type, presence: true
validates :published_at, presence: true, if: :will_be_published?
validates :thumbnail,
content_type: %w[image/png image/jpg image/jpeg],
content_type: %w[image/png image/jpeg],
size: { less_than: 10.megabytes }

paginates_per 24
Expand Down
2 changes: 1 addition & 1 deletion app/models/authored_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AuthoredBook < ApplicationRecord

validates :cover, attached: false,
content_type: {
in: %w[image/png image/jpg image/jpeg image/gif],
in: %w[image/png image/jpeg image/gif],
message: 'はPNG, JPG, GIF形式にしてください'
}

Expand Down
2 changes: 1 addition & 1 deletion app/models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Book < ApplicationRecord
validates :price, presence: true, numericality: { only_integer: true }
validates :page_url, presence: true
validates :cover,
content_type: %w[image/png image/jpg image/jpeg],
content_type: %w[image/png image/jpeg],
size: { less_than: 10.megabytes }

def cover_url
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def validate_uploaded_avatar_content_type
return unless uploaded_avatar

mime_type = Marcel::Magic.by_magic(uploaded_avatar)&.type
return if mime_type&.start_with?('image/png', 'image/jpg', 'image/jpeg', 'image/gif', 'image/heic', 'image/heif')
return if mime_type&.start_with?('image/png', 'image/jpeg', 'image/gif', 'image/heic', 'image/heif')

errors.add(:avatar, 'は指定された拡張子(PNG, JPG, JPEG, GIF, HEIC, HEIF形式)になっていないか、あるいは画像が破損している可能性があります')
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Work < ApplicationRecord
message: 'は「http://example.com」や「https://example.com」のようなURL形式で入力してください'
}
validates :thumbnail,
content_type: %w[image/png image/jpg image/jpeg],
content_type: %w[image/png image/jpeg],
size: { less_than: 10.megabytes }

def thumbnail_url
Expand Down

0 comments on commit b7a9870

Please sign in to comment.