Re: Rails DB convention info is a big fat secret?


#1

http://api.rubyonrails.com/files/vendor/rails/activerecord/README.html

Then off through the second “read more” to learn about associations.

http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethod
s.html#M000474

Your big secret table linking name is actually the most clear of the
documentations:

has_and_belongs_to_many(association_id, options = {}, &extension)
Associates two classes via an intermediate join table. Unless the join
table is explicitly specified as an option, it is guessed using the
lexical order of the class names. So a join between Developer and
Project will give the default join table name of “developers_projects”
because “D” outranks “P”.

The documentation for the other table bindings is not quite as clear
(you have to read the doc to get it), but it’s all there.

Anything you don’t understand, the nice people at
http://lists.rubyonrails.org/mailman/listinfo/rails are sure to be able
to help.

#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared
by NetIQ MailMarshal
#####################################################################################


#2

http://api.rubyonrails.com/files/vendor/rails/activerecord/README.html

Then off through the second “read more” to learn about associations.

You mean “Associations between objects controlled by simple
meta-programming macros?”

Hmm.

http://api.rubyonrails.com/classes/ActiveRecord/Associations/
ClassMethod
s.html#M000474

“Associations are a set of macro-like class methods for tying objects
together through foreign keys.”

But this is well past what I was looking for. It covers the database’s
foreign key structure. That comes after just getting the, hmm, I guess
the “ActiveRecord” doodad to auto-guess from the database itself. The
first link on that page, “Automated mapping between classes and tables,
attributes and columns” seemed like what I wanted when I first hit all
this documentation, but that doesn’t tell me the critical information
either. It says “see the mapping rules in table_name”, but there aren’t
any mapping rules there either. It links to the “inflector” class,
which is even more obscure, but I still haven’t even run across Rule
#1: “a table must have an autoincrementing integer named “id” as a
primary key requirement” or didn’t recognize it if I did.

Your big secret table linking name is actually the most clear of the
documentations:

has_and_belongs_to_many(association_id, options = {}, &extension)
Associates two classes via an intermediate join table. Unless the join
table is explicitly specified as an option, it is guessed using the
lexical order of the class names. So a join between Developer and
Project will give the default join table name of “developers_projects”
because “D” outranks “P”.

I still don’t see anything that says what the column names have to be.
{scratch head} Oh, wait, no, there are little pieces here and there.
Oh, my gosh. OK, I learned a new rule: “Don’t have a column named ‘id’
in a linking table.” It’s at the very bottom of the page.

Anything you don’t understand, the nice people at
http://lists.rubyonrails.org/mailman/listinfo/rails are sure to be able
to help.

Yes, but I’d hoped to avoid having to subscribe to another firehose of
a mailing list. I’d hoped that I’d just managed to miss the document I
was seeking, and somebody would say soomething like “oh, here’s
http://the-file-you-misssed-stupid.org/cluephone.html” or the like.
Apparently not. Sigh.

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.)

I haven’t used DarwinPorts yet. I’ve used Fink, with a 50% success
rate. (See http://howell.seattle.wa.us/essays/Unix5.html if you like to
watch trains wreck.) I’ve used CVS a few times; again, works sometimes.
The preposterously over-programmed iInstaller is required for TeX; it
usually works, it’s just a pain in the ass to use because of its lousy
user interface. Gems usually works, but of course only for Ruby
components, and some things (RubyCocoa for instance) aren’t available
as a gem. Also, Gems completely mangled its self-upgrade, which
eventually drove me to scrub all the Ruby I could find from my system
and re-install everything from scratch.

Gems installed Rails incorrectly the first time, and when I finally got
it installed, it worked only as long as I didn’t try to access my
database. Any attempt to do so would freeze something up, resulting in
the browser eventually timing out, and requiring me to restart Apache.

I’m apparently under a curse. I had to reinstall OSX Server three times
before it worked properly, and even now, the web server is completely
screwed; it returns 304 Forbidden errors for absolutely everything,
including its own default folders. Logging is set to maximum, but the
log messages are meaningless, and undocumented. (“10.0.2.13 - -
[23/Dec/2005:11:45:34 -0800] “GET / HTTP/1.1” 403 287 forbidden:/”
Nowhere on the Web can I find any reference to what Apache thinks its
doing when it tries to access my ‘forbidden:’ device, of which there
isn’t one, of course.)

This ought to give you some idea of why there’s no way I’m installing
Ruby or Rails or anything until I’m positive that my current latest
install, Postgres, is running perfectly. I won’t know that until I have
the database installed. I won’t have the database installed until I
finish the schema, and I won’t finish the schema until I find adequate
documentation on the requirements. Which apparently don’t yet exist.

I like Ruby, I really do. I just dread ever having to screw around with
the hell that awaits me when trying to run any command-line based
installer.