Rails noob db questions


#1

Hi, I’m trying to get my head around rails, but the documentation seems
sparse at best (and manuals.rubyonrails.com is unreachable from my
location
for whatever reason). I’m trying to figure out a few things:

  1. The documentation for the magicfields mentions using datetimes
    instead of
    timestamps, which pgsql doesn’t appear to support. What’s the answer in
    this
    case?

  2. All the tutorials seem to be geared towards trivial data
    relationships.
    What if I have table SHOP and table PERSON, but each record in SHOP has
    a
    OWNER, MANAGER, and a collection of EMPLOYEES. How should you structure
    this
    in your tablespace to take the best advantage of activerecord?

  3. Am I wrong in the assumption that all this needs to be sorted out at
    the
    database level before I go and generate models and controllers? Where do
    you
    put code that you don’t want to get blatted if and when the schema
    changes
    and you need to regenerate?

TIA,
-Josh


“wookin’ pa nub in all da wong paces, wookin’ pa nub”

          [ Josh 'G-Funk' McDonald ]  --   [ 0437 221 380 ]

#2

On Tue, 2006-03-28 at 10:01 +1000, Josh McDonald wrote:

Hi, I’m trying to get my head around rails, but the documentation
seems sparse at best (and manuals.rubyonrails.com is unreachable from
my location for whatever reason). I’m trying to figure out a few
things:

  1. The documentation for the magicfields mentions using datetimes
    instead of timestamps, which pgsql doesn’t appear to support. What’s
    the answer in this case?

fields named ‘created_on’ ‘updated_on’ ‘created_at’ ‘updated_at’ should
work

  1. All the tutorials seem to be geared towards trivial data
    relationships. What if I have table SHOP and table PERSON, but each
    record in SHOP has a OWNER, MANAGER, and a collection of EMPLOYEES.
    How should you structure this in your tablespace to take the best
    advantage of activerecord?

I think the Active Web D. With Rails discusses this - so does
some of the wiki pages…I think it’s called STI (single table
inheritance) - that would be one way of handling the employees, owners,
managers within one table.

  1. Am I wrong in the assumption that all this needs to be sorted out
    at the database level before I go and generate models and controllers?
    Where do you put code that you don’t want to get blatted if and when
    the schema changes and you need to regenerate?

Not at all…I think you are on the mark…get it sorted out now before
you have to go back and fix a bunch of forms/lists/etc.

Craig