Cannot this sort of scaffolding be driven off the domain model
relationships? It shouldn't need to involve database metadata.

On a related note, I tried a script to scaffold a set of ActiveRecord
model objects complete with relationships based on foreign and primary
key constraints in Oracle. It worked reasonably well, but determining
appropriate cascade behaviour was unreliable. Enabling cascades in
Oracle and in ActiveRecord felt like a bad idea.

PS There is a patch kicking around to support per-table sequences. I
expect this will get merged into the OCI adapter sometime.

Jim Cain wrote:
> On Apr 7, 2005 9:41 AM, Gavin Kistner <gavin / refinery.com> wrote:
> > That made me wonder "why oh why doesn't this ridiculously useful
> > feature exist?!" Oh, the things you could do with scaffolding if
you
> > could determine not just what type of value a column is, but if
it's
> > required. If the AR classes had rich methods that described the
full
> > schema they reflected, joins to other classes per column, and so
on.
> > Think of scaffolding that did client- and server-side validation of
> > required fields...that used forign-key references to create
drop-downs
> > for associated tables. Oh, the automated beauty that could be
realized!
>
> I've recently been investigating using Rails for a current project of
> mine. The backend is Oracle9i (hopefully soon to be 10g), and with
> Oracle you can discover all you could ever want to know about the
data
> model using its data dictionary.
>
> Adding standard methods to AR's database adapter model to support
such
> things shouldn't be too difficult. For example, to populate
drop-downs
> for foreign keys, it could look for an appropriate method in the
> adapter. If the database supports discovering fkeys, then the method
> exists; if not, it doesn't, or returns nil or something appropriate.
>
> Another thing that should change is sequence generation. Just because
> MySQL has a datatype that supports this directly in a table doesn't
> mean all databases do. There should be a way to use a table-specific
> function to generate a unique ID, such as sequences in Oracle.
>
> If there is real value in these changes, I wouldn't mind contributing
> some of them myself.
>
> As an aside, I'm excited to have a project that I might be able to
use
> Ruby for, and it gives me an opportunity to update my Oracle driver
> (Ruby9i) for the first time in over a year. I just bought the pickaxe
> book (2nd ed.) in anticipation of this.