Forum: Ruby Rails DB convention info is a big fat secret??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
12271b6df73fe29930d65586be5a4a70?d=identicon&s=25 Dave Howell (Guest)
on 2005-12-21 05:41
(Received via mailing list)
I started learning Ruby in part so I could do some web scripting, and
have already twice tried installing Rails, with my usual catastrophic
installer-malfunction-experiences with Ruby-related material. (I like
Ruby, but I *hate* having to install it.) At the moment I have a brand
new XServe with a nice fresh install of stuff. I have not yet tortured
it (and myself) with Ruby or Rails yet. Ruby's just on my laptop for
now, and Rails isn't going on anything until I'm ready.

One of the "getting ready" things is rebuilding and repopulating a
PostgreSQL database. As it happens, I can afford to redesign the
schema, since we're retiring the current apps that use it. Now, I've
seen bits and pieces of some very specific expectations that Rails has
for databases.

So why is the complete description a Rails-conformant database a giant
secret? I've Googled all over the web trying to find what, logically,
ought to be right up front in big bold type on the rubyonrails.org home
page: how to name/design a database so Rails "gets it."

The only thing I've found so far that even comes close was in a PDF
file, specifically Jeffrey Hick's "Many to Many" tutorial. Um? That's
preposterously obscure, or so it seems to me.

So far, I've got that it wants my table names to be plural, that trying
to use anything other than an autoincrementing integer named "id" for
the identity column is likely to be a real PITA, that foreign keys have
to be [tablename][underscore]"id", and (a secret exclusively in Hick's
article), linking tables must be named after the two tables to which
they link, and in alphabetical order!

So what other secrets should I have, and why isn't this the very first
article in the database-related Wiki articles or otherwise located so
that I'm tripping over it, instead of scratching my head?

Lugubriously,
a not-easily-dissuaded Ruby newbie.
918c6daad03c85e51ad1a11f57017947?d=identicon&s=25 Devin Mullins (Guest)
on 2005-12-21 06:11
(Received via mailing list)
Dave Howell wrote:

> I started learning Ruby in part so I could do some web scripting, and
> have already twice tried installing Rails, with my usual catastrophic
> installer-malfunction-experiences with Ruby-related material. (I like
> Ruby, but I *hate* having to install it.) At the moment I have a brand
> new XServe with a nice fresh install of stuff. I have not yet tortured
> it (and myself) with Ruby or Rails yet.

My recommendation: Use DarwinPorts to install Ruby, RubyGems, and your
DB, and use RubyGems to install Rails and any other Ruby libraries, and
you'll be much happier. (Fink might be fine, instead of DP; never used
it.)

> that foreign keys have to be [tablename][underscore]"id", and (a
> secret exclusively in Hick's article), linking tables must be named
> after the two tables to which they link, and in alphabetical order!

Have you been to http://api.rubyonrails.org/ ?

Also, please check out the Rails mailing list.

And welcome to the fold! Sort of!

Devin
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2005-12-21 06:17
(Received via mailing list)
On 12/20/05, Dave Howell <groups@grandfenwick.net> wrote:
> So why is the complete description a Rails-conformant database a giant
> secret? I've Googled all over the web trying to find what, logically,
> ought to be right up front in big bold type on the rubyonrails.org home
> page: how to name/design a database so Rails "gets it."

In general you'll have better luck on the Rails mailing list, but..
Check out the readme:
http://api.rubyonrails.com/files/vendor/rails/acti...
..and the API docs:
http://api.rubyonrails.com/classes/ActiveRecord/Base.html
..and the list of 'magic names'
http://wiki.rubyonrails.com/rails/pages/MagicFieldNames

Also, most people are just buying the book. It's quite nice, and
available in PDF form:
http://www.pragmaticprogrammer.com/titles/rails/index.html
This topic is locked and can not be replied to.