instance method
content_type=
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v2.3.18Signature
content_type=(mime_type)
Sets the HTTP response’s content MIME type. For example, in the controller you could write this:
response.content_type = "text/plain"
If a character set has been defined for this response (see charset=) then the character set information will also be included in the content type information.
Parameters
-
mime_typereq
Source
# File actionpack/lib/action_controller/response.rb, line 66
def content_type=(mime_type)
new_content_type =
if mime_type =~ /charset/ || (c = charset).nil?
mime_type.to_s
else
"#{mime_type}; charset=#{c}"
end
self.headers["Content-Type"] = URI.escape(new_content_type, "\r\n")
end
Defined in actionpack/lib/action_controller/response.rb line 66
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Response