From 6e48cd202cae0f5fc7419d368e70070aa35b0fc5 Mon Sep 17 00:00:00 2001 From: Tore Darell Date: Wed, 5 Nov 2008 00:04:40 +0100 Subject: Add example to show how to add additional headers using the response object --- .../actioncontroller_basics/request_response_objects.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt b/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt index a9c65c31bc..06844f0a1e 100644 --- a/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt +++ b/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt @@ -31,3 +31,13 @@ The response object is not usually used directly, but is built up during the exe * location - The URL the client is being redirected to, if any. * content_type - The content type of the response. * charset - The character set being used for the response. Default is "utf8". + * headers - Headers used for the response. + +==== Setting custom headers ==== + +If you want to set custom headers for a response then `response.headers` is the place to do it. The headers attribute is a hash which maps header names to their values, and Rails will set some of them - like "Content-Type" - automatically. If you want to add or change a header, just assign it to `headers` with the name and value: + +[source, ruby] +------------------------------------- +response.headers["Content-Type"] = "application/pdf" +------------------------------------- -- cgit v1.2.3