I recently came across an issue in my Rails application where an empty string was always being included in an array of attached files even if no files had been uploaded.
This resulted in the attached_files
param always being passed to the controller and showing an array with an empty string [""]
if no files had been uploaded.
I got some help for my problem with this response, but my question is, in what scenario would you need to handle an empty collection with the default hidden field? Why is it useful to have it as the default behaviour?
It's like the way there's a hidden empty field created for a checkbox. It's done because if there's no field at all, then the HTML/CGI standard means that be no param is sent by the browser to the server. So there'd be no way to delete all attachments.