On my current project, custom http header variable need to be set while redirecting for http basic auth. Can I instruct redirect_to for custom headers ?
Thanks.
Rails allows you to add custom headers while redirecting. It is discussed in Rails guides.
10.2.1 Setting Custom Headers
If you want to set custom headers for a response then
response.headers
is the place to do it. Theheaders
attribute is a hash which maps header names to their values, and Rails will set some of them automatically. If you want to add or change a header, just assign it toresponse.headers
So your action code would end up being something like this:
def some_action
# do_some_work
response.headers["your-key"] = "some value"
redirect_to url
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With