I'm confused by the number of different modules that deal with mime types in Rails. There are three that I have in mind, if somebody could straighten this out for me I would be grateful.
1) Mime::Type (for respond_to)
Mime::Type.register "text/richtext", :rtf
2) MIME::Types (from the mime-types gem)
MIME::Types[/ogg/, :complete => true]
3) Rack::Mime::MIME_TYPES (for serving content)
Rack::Mime::MIME_TYPES.merge!({".ogg" => "audio/ogg"})
Are these three completely separate or is there any connection between them? It seems strange to maintain 3 different lists of mime types, but their purposes do seem disjoint, I guess.
More specifically, how should I know which of these to register a new type with?
Thanks!
The MIME types defined by Rails and your initializers are the methods that you call on the block object format or the symbols that you pass to respond_to. You may recognise these from the symbols passed to the Mime::Type.
MIME types—also sometimes called Internet media types or Content-types—describe the media type of content either contained in email or served by web servers or web applications, and are intended to help guide a web browser to correctly process and display the content.
What Does Multi-Purpose Internet Mail Extensions Type (MIME Type) Mean? Multi-Purpose Internet Mail Extensions (MIME) type is standard that helps in classifying the types of files used on the Internet. MIME types were originally developed as a standard to identify the message of an email body.
A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
Some waffle of an answer...
Rails (1) and Rack (3) were separate, so I guess that explains the split there - and hopefully at some point Rails will use the Rack one now that its Rack-based...
As for (2), this seems to be a non-Rails/Rack library for identifying a files type - http://mime-types.rubyforge.org/ - so perhaps the ideal future would be for Rails and Rack to be based on this... although it seems quite old now (2009) and is perhaps un-maintained, hence the lack of use...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With