module Spree class Attachment < Spree::Asset ATTACHMENT_ATTRIBUTES = %i[alt attachment_content_type attachment_file_name attachment_updated_at id position type].freeze PERMITTED_ATTACHMENT_ATTRIBUTES = %i[alt attachment position viewable_id viewable_type].freeze has_attached_file :attachment validate :no_attachment_errors validates_attachment :attachment, content_type: { content_type: 'application/pdf' } def no_attachment_errors errors.add :attachment, "Paperclip returned errors for file #{attachment_file_name}" if attachment.errors.any? end end end