Closed tuanmai closed 2 years ago
Hi @tuanmai!
I'm not quite sure what the problem you try to resolve with mapper inside after_clone
instead doing it inside after_persist
. You want to use mapper BEFORE any saving to DB to fix some associations, right? If so, could you add small test, please? There is good place for it .
Btw, you can extend existing models if they are not enough for your case.
@ssnickolay sure, I will add the test for it 👍
This is a great idea @tuanmai. Anything I can help with?
Summary
From this docs, I see that we can use
after_commit
to fix broken associations. But there is another use case that needs to fix the associations beforesave
, and it's better to inafter_clone
phrase.Example
When cloning org, to map
leave requests
to clonedleave categories
, we need to do it inafter_clone
step by usingmapper
.