I have tables Parents and CourseTypes,
When every parent interested in a course type, they submit their profile with course type ID, then in my application, Parents Table will call link() to save belongToMany association between them.
However, if you user click on interest button again, another link is created between 2 entities, which is identical to previous link.
I have tried to use Application Rules, check for uniqueness of parent_id and course_type_id on join table, but then link() will has runtime error like below:
Cannot commit transaction - rollback() has been already called in the nested transaction
I then tried to set the association with saveStrategy to ‘replace’ , on both side of associations, but dupplications still appear in database.
Please kindly point me a direction to go.
Thanks very much.