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). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Any ideas guys or is it ok to handle this approach? elioncho wrote:> 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).--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---