سؤال

Is there any class in Rails Api that lists all Content-Type for ActionController ?

Like HTML, JSON, XML, JS, etc.

هل كانت مفيدة؟

المحلول

Mime::EXTENSION_LOOKUP has all the available mime types.

Content type html would then be retrieved using Mime::EXTENSION_LOOKUP['html']:

[32] pry(main)> Mime::EXTENSION_LOOKUP["html"].to_s
=> "text/html"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top