Activity feeds for deletions (help on approach)

0 views
Skip to first unread message

elioncho

unread,
Feb 5, 2009, 3:09:22 AM2/5/09
to Ruby on Rails: Talk
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).


elioncho

unread,
Feb 5, 2009, 9:48:38 AM2/5/09
to Ruby on Rails: Talk
Any ideas guys or is it ok to handle this approach?

Zac Zheng

unread,
Mar 3, 2009, 12:18:14 PM3/3/09
to rubyonra...@googlegroups.com
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

--
Posted via http://www.ruby-forum.com/.

Reply all
Reply to author
Forward
0 new messages