igorkasyanchuk/active_storage_validations

No content_type validation on update (case of pdf files)

EricMbouwe opened this issue · 0 comments

I have this line in my Document model (in a rails 6 app)
validates :pdfs, attached: false, content_type: { in: 'application/pdf', message: 'Only PDF files !' }

When a user tries to update a Document with an invalid file (not pdf), the validation does not triggers and the update action runs, which results in my case a 500 server response.

Here is a case where I have added two invalid files and tried to update the document.

Screenshot 2023-03-14 at 1 47 54 PM

Let's look at what is happening.

Thanks.