Forum: Ruby on Rails How to override default DB settings...Connect to remote DB

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A07900bb10def5bf518f8383885c37b6?d=identicon&s=25 Prem Thilagar (premann)
on 2007-03-19 21:05
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

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 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
391f9b787cdc12aa2c179713f5103e3a?d=identicon&s=25 Ilan Berci (iberci)
on 2007-03-19 21:50
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 Fowler that goes into
detail with the exact scenario you describe:

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.

This topic is locked and can not be replied to.