When I want to set the HTTP response's content MIME type, should I use headers["content-type"]="text/html";
or response.content_type = "text/html"
What is the difference between the two? (I think there is no difference, just need confirmation.)
Which one is preferred usage in RoR?
You should use
response.content_type = Mime::HTML
The difference is that the former set the headers field directly. The latter is a method that also supports setting the charset at the same time if required.
Check the documentation here: http://api.rubyonrails.org/classes/ActionController/Response.html#M000593