Forum: Ruby on Rails Activity feeds for deletions (help on approach)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2009-02-05 09:09
(Received via mailing list)
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,

ElĂ­as

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).
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2009-02-05 15:49
(Received via mailing list)
Any ideas guys or is it ok to handle this approach?
E1af86717137575d94bed5d562c6f4f1?d=identicon&s=25 Zac Zheng (zaczheng)
on 2009-03-03 18:18
Elias Orozco wrote:
> Any ideas guys or is it ok to handle this approach?

On a somewhat related note, you might want to check out this plugin:
http://github.com/face/activity_streams/tree/master
This topic is locked and can not be replied to.