This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the workflows category.
Last Updated: 2024-11-23
When debugging the content_type
issue with the author upload, I saw that the
validation failed and I immediately jumped into the code to my custom
ContentTypeValidator
class and started debugging there. This was a mistake.
Had I paid attention to the console output, I would have seen that the
content_type
key was unexpectedly set to empty string ""
.
notes_file.errors
#<ActiveModel::Errors:0x000055ab6c68d3d8
@base=#<NotesFile:0x000055ab6e3c1148 id: nil, data_file_name: "K OHALLORAN SPIS Week 5_ Interpersonal Ties.docx", subject_id: 2246, created_at: nil, updated_at: nil, full_sample: nil, deleted_at: nil, page_count: nil, sample_text: nil, released_on: nil, author: nil, hidden_text: nil, slug: nil>,
@details=
{:data=>
[{:error=>:content_type_invalid,
:authorized_types=>
"application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, text/plain, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.slideshow, application/vnd.oasis.opendocument.text, application/vnd.oasis.opendocument.spreadsheet, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/vnd.oasis.opendocument.presentation",
:content_type=>""}]},
I.e. the answer was right there all along, under :content_type
. The caller was
at fault, not the class I was debugging.