# Help: production vs qa env

**URL:** <https://www.ruby-forum.com/t/help-production-vs-qa-env/88303>\
**Category:** Rails\
**Created:** [March 9, 2007, 3:17pm UTC](https://www.ruby-forum.com/t/help-production-vs-qa-env/88303 "2007-03-09T15:17:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [March 9, 2007, 3:17pm UTC](https://www.ruby-forum.com/t/help-production-vs-qa-env/88303/1 "2007-03-09T15:17:18Z")

</div>

I was wondering what the best practice is for determining whether you’re  
rails app is on a qa server or on the production server.

Here’s the scenario:

I have some google analytics scripts that I want to be activated only  
for  
the production server. I have a QA server which I run in production  
mode  
for testing purposes so I can’t use the RAILS\_ENV as the test. I was  
thinking of just setting another ENV variable, but don’t know if that’s  
the  
best way… Is there a better way?

thanks,  
a

–  
Andrew S.

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [March 9, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/help-production-vs-qa-env/88303/2 "2007-03-09T16:31:39Z")

</div>

Andrew S. wrote:

> I was wondering what the best practice is for determining whether you’re  
> rails app is on a qa server or on the production server.
> 
> Here’s the scenario:
> 
> I have some google analytics scripts that I want to be activated only for  
> the production server. I have a QA server which I run in production mode  
> for testing purposes so I can’t use the RAILS\_ENV as the test. I was  
> thinking of just setting another ENV variable, but don’t know if that’s the  
> best way… Is there a better way?

Well if the hostnames are different you can just do something like:

hostname = `hostname`

if hostname == “\<prod\_machine\>”  
…  
elsif hostname == “\<qa\_machine\>”  
…  
end

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [March 9, 2007, 5:03pm UTC](https://www.ruby-forum.com/t/help-production-vs-qa-env/88303/3 "2007-03-09T17:03:44Z")

</div>

Are your tests all coming from localhost? If so, you can test for  
that using @controller.local\_request?.
