Is the difference between has_one and _belongs_to that with has_one you
can use the additional parameters such as :dependent and :order? Or is
there more to it then that? Thanks,
-S
Is the difference between has_one and _belongs_to that with has_one you
can use the additional parameters such as :dependent and :order? Or is
there more to it then that? Thanks,
-S
On 19 Nov 2007, at 20:10, Shandy N. wrote:
Is the difference between has_one and _belongs_to that with has_one
you
can use the additional parameters such as :dependent and :order? Or is
there more to it then that? Thanks,
It’s about where the foreign key sits.
class Foo < AR:Base
end
if foo belongs_to :bar, then the foos table has a bar_id column
if foo has_one :bar,then the bars table has a foo_id column
Fred
On the conceptual level, if your class A has a has_one relationship
with class B then class A is the parent of class B hence your class B
will have a belongs_to relationship with class A since it is the child
of class A.
This is the reason (as Fred specified before), you will have a_id as
foriegn key in your table b
On Nov 19, 8:10 pm, Shandy N. [email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs