Get your http header infomation
ActionController has a key attribute:
“request”
which contains all http header attributes.
i.e:
def server_ip
location = request.env["SERVER_ADDR"]
render :text => "This server hosted at #{location}"
end
location = request.env["SERVER_ADDR"]
render :text => "This server hosted at #{location}"
end
To get root host url, type:
request.env["HTTP_HOST"]
more useful key attributes in ActionController:
- request
- params
- session
- response
