Question says it all.
(3 attempts)
dickdawg answered:
These relationships describe the composition and aggregate associations possible between classes. In OO terms, a class is composed of another if you have the following:
class Foo def initialize @bar = Bar.new end end
class Foo def initialize(bar) @bar = bar end end
BAR FOO +----+--------+ +----+~ | id | foo_id | | id | +----+--------+ +----+~ | 42 | 69 |------| 69 | ~----~--------~ ~-----~
BAR FOO ~+----+ +----+--------+ | id | | id | bar_id | ~+----+ +----+--------+ | 42 |------| 69 | 42 | ~-----~ ~----~--------+
Rayman answered:
class HasOne < RefersTo end
Now the difference between BelongsTo and RefersTo is, as far as I can tell, the following:
a.belongs_to b b.delete //Both got deleted since a.belongs_to b. a.refers_to b b.delete // a is still alive and kicking !
So it's about relation travelsal.
capiCrimm answered:
I'm fairly sure it just describes ownership of the record.
If ORMA has_one ORMB, then ORMA has a field that contains the linked ORMB's. If ORMB belongs_to ORMA, then ORMB has a field that contains the linked ORMA's.
I'm guessing, and I might be wrong. :D