fearless_fool wrote:
> @Marnen: first, apologies on the misspelling -- no slight intended.

None assumed.

> 
> After thrashing around on this forum and working through AWDwR, I can
> pose my question more succinctly.  But bear with me if I still get it
> wrong...
> 
> * You use migrations to define / extend / modify the tables in your
> db.

Right.

> 
> * ActiveRecord dynamically analyzes the tables in your db and from
> that, builds glue routines between Ruby and your db.

Not really.  ActiveRecord looks at the fields in each table and uses 
that information to build SQL queries and return the results as Ruby 
objects.  That's basically it.

> 
> If that's the case, why does one need to include belongs_to, has_many,
> has_one (etc) in subclasses of ActiveRecord?  

Because ActiveRecord doesn't automatically detect table relationships. 
Indeed, without foreign key constraints (which not all databases 
support), there is *no way* that it could conceivably do so reliably.

> Since the relationships
> between tables are described by the tables themselves, it seems
> blatantly un-DRY to specify such relationships in two places.  

The relationships are actually not described by the tables in all cases, 
at least not in a way that is susceptible to deduction.

>(My
> belief that all Rails code was DRY may have been my source of
> confusion in previous posts...)

That belief is not 100% correct. :)

> 
> Case in point: the line_item table in the AWDwR depot example appears
> as follows.  Can't Rails deduce the LineItem#belongs_to, the
> Product#has_many and the Order#has_many relationships from this?

No.

> 
> - ff

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to