Callbacks not triggered when used in combination with activerecord-import
vsolari opened this issue · comments
vsolari commented
Currently I use the 'activerecord-import' gem in some functionalities, when the insertion is done through "import", the "public_activity" does not insert the activity. Is there a way to record the movement of large volumes of data?
Juri Hahn commented
This is not a bug in PublicActivity but a tradeoff of using activerecord-import which is documented here: https://github.com/zdennis/activerecord-import#callbacks. It’s the same with counter caches, also documented a bit further up: https://github.com/zdennis/activerecord-import#counter-cache
As far as I can tell, you have 2 options:
- either you configure the
#import
to trigger the callback (for each record!) - or you manually create PublicActivity data for imported objects using yet another
import
call. The mentioned links provide some strategies and possible workarounds.
Juri Hahn commented