# Database.yml question

**URL:** <https://www.ruby-forum.com/t/database-yml-question/106635>\
**Category:** Rails\
**Created:** [June 12, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/database-yml-question/106635 "2007-06-12T17:21:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DBC\_User](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@DBC\_User](https://www.ruby-forum.com/u/DBC_User)\
**Post date:** [June 12, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/database-yml-question/106635/1 "2007-06-12T17:21:12Z")

</div>

Based on what I read, database.yml has the config pointing to all 3  
different environment. You can use rake to move the schema from one  
environment to another. How will the rails know it is running in  
development or testing or data center environment to use appropriate  
database ?  
Thanks.

---

<div class="post-metadata">

**Author:** ![DBC\_User](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@DBC\_User](https://www.ruby-forum.com/u/DBC_User)\
**Post date:** [June 12, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/database-yml-question/106635/2 "2007-06-12T18:37:34Z")

</div>

> Based on what I read, database.yml has the config pointing to all 3  
> different environment. You can use rake to move the schema from one  
> environment to another. How will the rails know it is running in  
> development or testing or data center environment to use appropriate  
> database ?

I think be default at the top of config/environment.rb there is a line  
that sets RAILS\_ENV to development unless it’s already been set  
elsewhere  
in the environment.

So by default you’re gonna end up in ‘development’. Otherwise it  
depends  
on how you start up rails. Each web server has it’s own way of  
indicating  
the environment rails should start up in.

And things like script/console and script/runner take the argument on  
the  
command line if you want to change it.

-philip

---

<div class="post-metadata">

**Author:** ![DBC\_User](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@DBC\_User](https://www.ruby-forum.com/u/DBC_User)\
**Post date:** [June 12, 2007, 8:40pm UTC](https://www.ruby-forum.com/t/database-yml-question/106635/3 "2007-06-12T20:40:05Z")

</div>

On Jun 12, 11:43 am, Philip H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So by default you’re gonna end up in ‘development’. Otherwise it depends  
> on how you start up rails. Each web server has it’s own way of indicating  
> the environment rails should start up in.
> 
> And things like script/console and script/runner take the argument on the  
> command line if you want to change it.
> 
> -philip

Thanks for the information.
