Many to many relation in one model


#1

Hi you all,

I have a model called Property where a property is related with many
properties.
I was gonna deal with this by having a has-and-belongs-to-many relation
but… what should I write in the SQL database? Would it be a
“properties_properties” table? And the attributes? :S

Thanks.


#2

This is called a self-referential association. If you Google for “rails
self-referential” you’ll get a lot of useful stuff.

/afb


#3

Adam B. wrote:

This is called a self-referential association. If you Google for “rails
self-referential” you’ll get a lot of useful stuff.

/afb

Thanks! searching I found a very useful article :slight_smile: :
http://www.fallenrogue.com/article/view/143-I-am-what-I-am-or-self-referential-joins-in-Rails