Im trying to get to set a validation on the storing .yml files only. With some research I'm doing this:
class TranslationFile < ApplicationRecord
has_one_attached :file
validate :only_yml_type
private
def only_yml_type
if file.attached? && !file.content_type.in?(%w(application/x-yaml))
file.purge
errors.add(:file, 'Must be a yaml file')
end
end
end
but now even if the file is .yml / .yaml I can't store it, am I doing anything wrong?