What is the deal with the mime type in Rails?

I am confused by the number of different modules that are related to the mime types in Rails. There are three that I mean, if someone can fix this for me, I would be grateful.

1) Mime :: Type (for reply_to)

Mime::Type.register "text/richtext", :rtf 

2) MIME :: Types (from mime-type gemstone)

 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 separated or is there any connection between them? It seems strange to maintain 3 different lists of mime types, but their goals seem to be disjoint, I think.

In particular, how do you know which ones register a new type with <

Thanks!

+6
source share
1 answer

Some answer waffles ...

Rails (1) and Rack (3) were separate, so I think this explains the split there - and hopefully at some point Rails will use Rack now that its Rack-based ...

As for (2), this is apparently a non-Rails / Rack library for identifying file types - http://mime-types.rubyforge.org/ - so perhaps an ideal future would be for Rails and Rack based on this ... although it seems that it is quite old (2009) and may not be supported, therefore, the lack of use ...

+1
source

Source: https://habr.com/ru/post/886035/


All Articles