How to track custom events in paper_trail?

I have found a tweak to add custom events in paper_trail managed Versions. Here is the tweak

Version.create(item_type: "Campaign", item_id: campaign.id, event: "Sent")

May be this is not right solutions but it helped me to achieve the goal. I would explore paper_trail more to find obvious solution.

Please keep posting your suggestions.

Thanks, Amit Patel


See simple hit counter for page views in rails as an answer to the first part of your question. As for tracking sent mails, you may want to use Observer pattern.

In any case all these events are outside of paper_trail domain. While paper_trail simply creates versions of your model during data changing, what you need is to observe custom event and write to DB all necessary information about that event.