Skip to content

Translate the file content types to human readable format #45

@ahukkanen

Description

@ahukkanen

Given that I have the following model:

class Profile
  include ActiveModel::Validations

  attr_accessor :avatar
  validates :avatar, file_content_type: { allow: ['application/json'] }
end

I will get the following error message when the file is not valid:

allowed_file_content_types: ! 'file should be one of %{types}'

With the allowed content type interpolated as specified in the validate statement, i.e. application/json as defined here:

error_options = options.merge(types: option_types.join(', '))

I suggest that we would convert the Mime type into human readable format, e.g. in this case JSON.

This could be done e.g. as follows:

"application/json".match(%r{/([a-z]+)})[1].upcase

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions