Many-to-many relationship to table itself through other table

Hello,

I would like to have many-to-many relationship to object itself with
additional info, but I did not find any info on that, could someone
suggest something?

Example:

Service
-- name
-- description

ServiceConnection
-- type
-- description
-- parent_id
-- child_id

Have a look at has_many :through with class_name and foreign_key. You
will need two of these, one for parents and one for children.
has_many :service_connections
has_many :parents, :through => :service_connection, :class_name..... etc
has_many :children, :through => :service_connection, :class_name..... etc

The rails guide on activerecord associations at
http://guides.rubyonrails.org/ should help.

Colin

mxrgus pxrt wrote: