# Using 2 database into a single RoR application

**URL:** <https://www.ruby-forum.com/t/using-2-database-into-a-single-ror-application/175603>\
**Category:** Rails\
**Created:** [September 16, 2009, 11:31am UTC](https://www.ruby-forum.com/t/using-2-database-into-a-single-ror-application/175603 "2009-09-16T11:31:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ialuronico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@ialuronico](https://www.ruby-forum.com/u/ialuronico)\
**Post date:** [September 16, 2009, 11:31am UTC](https://www.ruby-forum.com/t/using-2-database-into-a-single-ror-application/175603/1 "2009-09-16T11:31:25Z")

</div>

Hi everybody,

I’m trying to convert to Ror one of my old ASP classic project.

the website is an e-commerce with a community

In this website I have 2 separate database for products/BI and for user  
generated content so is easyer to develop BI without touching the “user”  
database.

Pubblishing a new BI or a mayor database update is just matter of  
drop/restore  
the full BI database.

Also we can keep our development environment and staging environment on  
sync with user generated content just by dropping the user database and  
restoring a backup from production.

How can I make this in Ror ?

thanks

---

<div class="post-metadata">

**Author:** ![ialuronico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@ialuronico](https://www.ruby-forum.com/u/ialuronico)\
**Post date:** [September 16, 2009, 11:58am UTC](https://www.ruby-forum.com/t/using-2-database-into-a-single-ror-application/175603/2 "2009-09-16T11:58:24Z")

</div>

You can tell rails to use different databases on a per-model basis. Just  
put a

establish\_connection :dbname

in the model class, and make sure there’s a definition for ‘dbname’ in  
config/database.yml.

steve

---

<div class="post-metadata">

**Author:** ![ialuronico](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@ialuronico](https://www.ruby-forum.com/u/ialuronico)\
**Post date:** [September 16, 2009, 1:35pm UTC](https://www.ruby-forum.com/t/using-2-database-into-a-single-ror-application/175603/3 "2009-09-16T13:35:26Z")

</div>

You will need to restart the Rails application that is running in  
production mode if you change the schema.

On Sep 16, 2:31 pm, “Simone R.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
