How do I work with an EXISTING database?

I have a standalone Ruby script that downloads web pages, scrapes data
from
these downloaded pages, and stores the results in a Postgres database.
This script is to run nightly. (My project is called Bargain Stock
Funds.
This database stores data on mutual funds and ETFs.)

I am working on a Rails web site that needs to read data from this
Postgres
database and display information on selected mutual funds and/or ETFs…

How do I work with a database that already exists? The tutorials and
examples out there seem to focus on creating a database rather than
working
with a pre-existing one.

On Apr 19, 2013, at 5:15 PM, Jason H., Android developer wrote:

I have a standalone Ruby script that downloads web pages, scrapes data from
these downloaded pages, and stores the results in a Postgres database. This
script is to run nightly. (My project is called Bargain Stock Funds. This
database stores data on mutual funds and ETFs.)

I am working on a Rails web site that needs to read data from this Postgres
database and display information on selected mutual funds and/or ETFs…

How do I work with a database that already exists? The tutorials and examples
out there seem to focus on creating a database rather than working with a
pre-existing one.

If your database is structured the way rails wants it, there’s nothing
more to do than define a model for each table.

If your table names are not named the way Rails would name them, there’s
a method you use in the model class to specify the name.

If you primary key field is not named id, there’s a method…

And so on for many other things.

If you do not have an integer primary key, then things get difficult.

But if you have integer primary keys on each table, then really you just
need to be looking at the model class docs to figure out how to handle
your tables.


Scott R.
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice