Hi!
We have a comment model that can have many comments as childrens.
...
has_many :childrens, class_name: self.to_s, foreign_key: :parent_id
belongs_to :parent, class_name: self.to_s, foreign_key: :parent_id
...
In it's factory, we have a trait to handle this associations, so we can create a comment with many children comments.
...
trait :with_childrens do
after(:create) do |comment|
create_list(:comment, parent: comment)
end
end
...
But it a exception is raised: "FactoryGirl::AssociationDefinitionError: Self-referencing association 'parent' in 'comment'"
How can we treat this?
Regards,