Ruby get mime-type based on extension

mime-types, ruby, ruby-on-rails

Solution

If you are using Rails you can get the mime-type with Rack::Mime.

mime_type = Rack::Mime.mime_type(extension)

Problem

How can I get a mime-type based on a file extension?

Original source