Use the debugger to check params[:mailing_search]
in your controller.
I suspect params[:mailing_search][:search_config].content_type
will be application/octet-stream
since a .yml file is treated as binary.
Since you don't allow application/octet-stream
as a valid content type, that's why you get the error.
When you try through the console the content type is not being overridden by the browser, hence why it works.
In your controller, before building @search
, you can reset the content type in the params to the file's MIME type using:
params[:mailing_search][:search_config].content_type = MIME::Types.type_for(params[:mailing_search][:search_config].original_filename).first.content_type
This should preserve text/x-yaml
as the content type for the file which you allow as valid.