Activity feeds for deletions (help on approach)

Hello guys,

I created activity feeds for my project using a polymorphic model called feed. The table contains the following columns:

resource_id resource_type user_id project_id

Everytime I added a record its feed was added via an observer and everytime it was deleted the feed was gone too. The problem is that I now want to have a feed for deleted records.

Problem: When I delete a record now, the original feed stays unerased and when I render the activity feeds I can no longer use the resource_id value to find data to display cause that id it no longer exists.

I decided to use two extra columns. One to save a common name that I could use on my deleted record feeds. For example if my feed said "Roger has been created", (roger which is the name of the user, was found via the resource_id) now I saved that name to a new column called resource_name. That way I could look into that column to write my feed: "Roger has been deleted" once the record gets deleted. The second column will be one called action that will let me know if the feed was for a "create" or "destroy" action, which will help me on displaying the feed message accordingly.

So what are your opinions on this approach. Do you have any ideas to optimize it or a whole new better approach?

Thanks for your time,


P.S. By the way, when a record is deleted I want it to be truly deleted. I don't want an approach where I could add a deleted_at column to keep the record unused but available to help me on referencing the resource_id).

Any ideas guys or is it ok to handle this approach?

elioncho wrote: