Written by Sean Behan on Sun Jun 17th 2012

When mime types are registered they are placed in a hash constant EXTENSION_LOOKUP in the module Mime. For reference, the file with the relevant code is in rails/action_pack/lib/action_dispatch/http/mime_type.rb available on Github at https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/mime_type.rb

You can check for existence of certain mime types with

which will return the object or nil if it's not registered. You can also iterate over all registered mime types by cycling through the constant like so
Mime::EXTENSION_LOOKUP.each { |m| puts m}

Api documentation is here: http://api.rubyonrails.org/classes/Mime/Type.html#method-c-lookup_by_extension

Tagged with..
#content types #mime types #rails core #rails source #responders #rails source

Just finishing up brewing up some fresh ground comments...