Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails list all valid content types

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

Like HTML, JSON, XML, JS, etc.

like image 672
swapab Avatar asked Nov 16 '25 18:11

swapab


1 Answers

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"
like image 80
vee Avatar answered Nov 18 '25 08:11

vee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!