Associations between 2 items of the same model

Hi,
I wondering if it’s possible to make an association between 2 items of the same model. Example: my model is Person and I want to make an association between a certain Person (mother) and another Person (son).
Is that possible?
Thanks

Hi,

Yes, you could do something like…

  schema "persons" do
    field(:first_name, :string)
    ....
    has_many(:relationships, Relationship, foreign_key: :person_a_id)
  end

  schema "relationships" do
    belongs_to(:person_a, Person)
    belongs_to(:person_b, Person)
    belongs_to(:relationship_type, RelationshipType)
  end

:many_to_many would work as well, and might cut down on some boilerplate (can point “directly” to another person bypassing the “relationships” connection).