# Environment variables

**URL:** <https://www.ruby-forum.com/t/environment-variables/117062>\
**Category:** Rails\
**Created:** [October 12, 2007, 4:43pm UTC](https://www.ruby-forum.com/t/environment-variables/117062 "2007-10-12T16:43:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leo\_Tolstoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e19adc/32.png) [@Leo\_Tolstoy](https://www.ruby-forum.com/u/Leo_Tolstoy)\
**Post date:** [October 12, 2007, 4:43pm UTC](https://www.ruby-forum.com/t/environment-variables/117062/1 "2007-10-12T16:43:44Z")

</div>

Can anyone help me to find out the syntax to access the environment  
variable that has the site domain? Maybe HTTP\_HOST?  
i have tried to find documentation on how to access such a variable,  
but with no luck. Can someone help me (even if it is just pointing me  
in the right direction for searching)?  
Thanks,  
Tolstoy

---

<div class="post-metadata">

**Author:** ![Leo\_Tolstoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e19adc/32.png) [@Leo\_Tolstoy](https://www.ruby-forum.com/u/Leo_Tolstoy)\
**Post date:** [October 13, 2007, 1:03pm UTC](https://www.ruby-forum.com/t/environment-variables/117062/2 "2007-10-13T13:03:54Z")

</div>

The three biggies are

- params
- response
- session

I think you will find HTTP stuff in response (just do a ‘puts  
response.inspect’)…

---

<div class="post-metadata">

**Author:** ![Leo\_Tolstoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e19adc/32.png) [@Leo\_Tolstoy](https://www.ruby-forum.com/u/Leo_Tolstoy)\
**Post date:** [October 13, 2007, 1:57pm UTC](https://www.ruby-forum.com/t/environment-variables/117062/3 "2007-10-13T13:57:05Z")

</div>

On 10/13/07, nigel.bris [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The three biggies are
> 
> - params
> - response
> - session
> 
> I think you will find HTTP stuff in response (just do a ‘puts  
> response.inspect’)…

This is a request thing, isn’t it?

I’d look in request.env, and possibly ENV.

---

<div class="post-metadata">

**Author:** ![Leo\_Tolstoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e19adc/32.png) [@Leo\_Tolstoy](https://www.ruby-forum.com/u/Leo_Tolstoy)\
**Post date:** [October 14, 2007, 5:01pm UTC](https://www.ruby-forum.com/t/environment-variables/117062/4 "2007-10-14T17:01:47Z")

</div>

I was able to get the effect that I was after by using the following  
in an rhtml file:  
http://\<%= request.server\_name %\>:\<%= request.server\_port %\>/  
This seems like a hack though. By inspecting \<%= debug(request.env) %\>  
I can see that “HTTP\_HOST” has the info that i am after, I just  
haven’t found a way to access that variable in an rhtml file.
