# Avoiding RAILS\_ENV

**URL:** <https://www.ruby-forum.com/t/avoiding-rails-env/141617>\
**Category:** Deployment\
**Created:** [June 27, 2008, 8:12pm UTC](https://www.ruby-forum.com/t/avoiding-rails-env/141617 "2008-06-27T20:12:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 27, 2008, 8:12pm UTC](https://www.ruby-forum.com/t/avoiding-rails-env/141617/1 "2008-06-27T20:12:58Z")

</div>

How do I avoid adding:  
export RAILS\_ENV=‘production’

How do I avoid setting my environment globally as production?

I have two sites on the same server:

/www/stage.example.com  
/www/test.excample.com

Both apps are using the same database after deployment, I’d like them  
not to be shared.

–  
Anthony E.  
408-656-2473  
[http://anthony.ettinger.name](http://anthony.ettinger.name)

---

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 27, 2008, 11:18pm UTC](https://www.ruby-forum.com/t/avoiding-rails-env/141617/2 "2008-06-27T23:18:01Z")

</div>

Well, assuming that you don’t have the database.yml in your SCM (which  
you shouldn’t)… you should be able to just set the production db to  
the different database for each one.

Robby

On Fri, Jun 27, 2008 at 11:11 AM, Anthony E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 

–  
Robby R.  
Chief Evangelist, Partner

PLANET ARGON, LLC  
design // development // hosting

> **[Planet Argon](https://www.planetargon.com/)**
>
> Planet Argon is a Ruby on Rails development agency specializing in maintenance and support for existing Rails apps. Based in Portland, OR, Planet Argon has been a member of the Rails community since 2004.

[http://www.robbyonrails.com/](http://www.robbyonrails.com/)  
aim: planetargon

+1 503 445 2457  
+1 877 55 ARGON [toll free]  
+1 815 642 4068 [fax]

---

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 29, 2008, 1:35pm UTC](https://www.ruby-forum.com/t/avoiding-rails-env/141617/3 "2008-06-29T13:35:48Z")

</div>

If you are like me, using capistrano,

1. add those lines below to deploy.rb:

task “[stage.example.com](http://stage.example.com)” do  
set :target, current\_task.name  
end

task “[test.example.com](http://test.example.com)” do  
set :target, current\_task.name  
end

task :replace\_configs do  
run “(cd #{release\_path}; cp config/deploy/#{target}/database.yml  
config)”  
end  
before “deploy:finalize\_update”, :replace\_configs

1. place database.yml for each target

config/deploy/stage.example.com/database.yml  
and  
config/deploy/test.example.com/database.yml

1. then, you can deploy each target

$ cap [stage.example.com](http://stage.example.com) deploy  
or  
$ cap [test.example.com](http://test.example.com) deploy

A recipe “Run Multi-Stage Deployments” in the book “Advanced Rails  
Recipes” describes such one  
[http://pragprog.com/titles/fr\_arr/advanced-rails-recipes](http://pragprog.com/titles/fr_arr/advanced-rails-recipes)

---

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 30, 2008, 9:03pm UTC](https://www.ruby-forum.com/t/avoiding-rails-env/141617/4 "2008-06-30T21:03:16Z")

</div>

Your production/staging servers should have a database.yml file that  
you symlink to during the deploy process.  
Robby

On Fri, Jun 27, 2008 at 5:20 PM, Anthony E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > the different database for each one.
> > 
> > > I have two sites on the same server:  
> > > 408-656-2473

–  
Robby R.  
Chief Evangelist, Partner

PLANET ARGON, LLC  
design // development // hosting

> **[Planet Argon](https://www.planetargon.com/)**
>
> Planet Argon is a Ruby on Rails development agency specializing in maintenance and support for existing Rails apps. Based in Portland, OR, Planet Argon has been a member of the Rails community since 2004.

[http://www.robbyonrails.com/](http://www.robbyonrails.com/)  
aim: planetargon

+1 503 445 2457  
+1 877 55 ARGON [toll free]  
+1 815 642 4068 [fax]

---

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 28, 2008, 2:21am UTC](https://www.ruby-forum.com/t/avoiding-rails-env/141617/5 "2008-06-28T02:21:10Z")

</div>

I currently do push the database.yml file, how should I do it without  
having that file on the server?

On Fri, Jun 27, 2008 at 2:17 PM, Robby R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > export RAILS\_ENV=‘production’
> 
> +1 503 445 2457  
> +1 877 55 ARGON [toll free]  
> +1 815 642 4068 [fax]
> 
> >

–  
Anthony E.  
408-656-2473  
[http://anthony.ettinger.name](http://anthony.ettinger.name)
