public-activity / public_activity

Easy activity tracking for models - similar to Github's Public Activity

Home Page:https://github.com/pokonski/public_activity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callbacks not triggered when used in combination with activerecord-import

vsolari opened this issue · comments

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?

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!)
    after_create :activity_on_create
  • or you manually create PublicActivity data for imported objects using yet another import call. The mentioned links provide some strategies and possible workarounds.