ancestry gem creating and editing people view forms

I wanna create and edit people but ancestry only provides for one parent_id so how can i have two on a form

I’d suggest you create your own solution without ancestry.

  I had a similar problem. I have an User model and each user must

has one or more parents and one or more children. So I created a join table called users_parents with two attributes user_id and parent_id . In my User model I added to has_and_belongs_to_many entries:

** has_and_belongs_to_many :parents, class_name: User, join_table: :users_parents, foreign_key: :user_id, association_foreign_key: :parent_id**

** has_and_belongs_to_many :children, class_name: User, join_table: :users_parents, foreign_key: :parent_id, association_foreign_key: :user_id**

  That way, I can add an user as parent of several users or an user

as child of several users.

my_user.parents will return all my_user parents and my_user.children will return all my_user children

Thanks What’s the difference between that and has_many through approach?

In my case, I didn’t need any additional attribute in my join table. So I user has_and_belongs_to_many . If you need additional attributes in you join table, you should create a model for it and use has_many through