# How to override default DB settings...Connect to remote DB

**URL:** <https://www.ruby-forum.com/t/how-to-override-default-db-settings-connect-to-remote-db/89357>\
**Category:** Rails\
**Created:** [March 19, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/how-to-override-default-db-settings-connect-to-remote-db/89357 "2007-03-19T21:05:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![premann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@premann](https://www.ruby-forum.com/u/premann)\
**Post date:** [March 19, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/how-to-override-default-db-settings-connect-to-remote-db/89357/1 "2007-03-19T21:05:45Z")

</div>

Hi everyone,  
i am pretty much a beginner to Ruby on rails,and i wanted to  
develop a complete monitoring system for a grid application using ruby  
on rails.But i wanted to override the default settings of the DB  
connections with Ruby on rails like the ORM and the plural names based  
DB table creations.  
This is my problem i already have a full DB stacked with data and i  
wanna use the data there,just use there there is going to be no creation  
of tables or not even insertions of data.  
I tried connecting to the remote db by making changes to the  
/config/database.yml and when i ran rake db:migrate,i got some error  
messages

i am sure i am doing some thing weird but do not have a idea where to  
start debugging from.can some one please suggest me a good point to  
start.to understand connecting to an existing remote DB by creating a  
new rails application from scratch  
I assume this is going to be necessary to override all the naming  
conventions in reagard to creation of models and stuff,if some one could  
please guide me through this it will be really helpful.  
thanks in advance  
prem

---

<div class="post-metadata">

**Author:** ![premann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@premann](https://www.ruby-forum.com/u/premann)\
**Post date:** [March 19, 2007, 9:50pm UTC](https://www.ruby-forum.com/t/how-to-override-default-db-settings-connect-to-remote-db/89357/2 "2007-03-19T21:50:26Z")

</div>

Prem Thilagar wrote:

> please guide me through this it will be really helpful.  
> thanks in advance  
> prem

There is a book entitled “Rails Recipes” by Chad F. that goes into  
detail with the exact scenario you describe:  
[http://www.pragmaticprogrammer.com/titles/fr\_rr/](http://www.pragmaticprogrammer.com/titles/fr_rr/)

In short, there is a migration task (forgot it’s name and I am at work)  
that will dump your current schema to a migration file. Next, you  
create the schema\_info table and bump it’s rev number… and voila, you  
now have your schema involved with migrations!

As for the ActiveRecord overrides, look at the rails documentation on  
which options to specify to your models to get them to work with a  
legacy db… it’s pretty straight forward and I was able to do it in the  
past with a relatively normalized database. If your database is a mess  
however, then it’s probably not worth the effort and you should probably  
try fixing your db model prior to rails integration…

OH… at the risk of being obvious or insulting, please dump your db  
prior to doing anything as the slightest mistake can be very costly. I  
don’t feel so bad because Chad mentions it too… 🙂

Fowler’s book is worth it’s weight in gold and it was a very cool read  
with a lot of "That is so f#$@#king cool! " episodes that I had to stop  
reading it before bedtime.

ilan
