A common pattern I''ve used in database application development is some form of ''state'' field that is used to administratively manage records. Rather than deleting records I will mark them with a state of ''deleted'' and it becomes an administrative task to actually later remove and/or archive them from the database. That way data never just disappears but there is a clear audit-trail and archive of all data. This implies that from an application view the records with a ''deleted'' state should disappear as if they are truly deleted. All queries must filter out those deleted records as if they don''t exist. Therefore there should be some filter automatically added to every query in the rails apps to be sure to exclude those records (WHERE state NOT ''deleted). I would prefer that this is transparent and that the application doesn''t have to always add this filter but that it is automatically handled by ActionRecord. What is the best way to achieve this with Rails? Is there already native ActionRecord capability for this or perhaps a plugin available for this functionality? Thanks, Mark --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 11, 2008, at 24:20 , Mark wrote:> A common pattern I''ve used in database application development is > some form of ''state'' field that is used to administratively manage > records. Rather than deleting records I will mark them with a state > of ''deleted'' and it becomes an administrative task to actually later > remove and/or archive them from the database. That way data never > just disappears but there is a clear audit-trail and archive of all > data. > > This implies that from an application view the records with a > ''deleted'' state should disappear as if they are truly deleted. All > queries must filter out those deleted records as if they don''t exist. > > Therefore there should be some filter automatically added to every > query in the rails apps to be sure to exclude those records (WHERE > state NOT ''deleted). I would prefer that this is transparent and > that the application doesn''t have to always add this filter but that > it is automatically handled by ActionRecord. > > What is the best way to achieve this with Rails? Is there already > native ActionRecord capability for this or perhaps a plugin > available for this functionality?I think the canonical solution in Rails is acts_as_paranoid. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you, it appears that acts_as_paranoid is exactly what I''m looking for. The following statement in the docs, "Most normal model operations will work, but there will be some oddities," does concern me a bit since those ''oddities'' are not at all defined. - Mark On Sun, Feb 10, 2008 at 6:39 PM, Xavier Noria <fxn-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:> > On Feb 11, 2008, at 24:20 , Mark wrote: > > > A common pattern I''ve used in database application development is > > some form of ''state'' field that is used to administratively manage > > records. Rather than deleting records I will mark them with a state > > of ''deleted'' and it becomes an administrative task to actually later > > remove and/or archive them from the database. That way data never > > just disappears but there is a clear audit-trail and archive of all > > data. > > > > This implies that from an application view the records with a > > ''deleted'' state should disappear as if they are truly deleted. All > > queries must filter out those deleted records as if they don''t exist. > > > > Therefore there should be some filter automatically added to every > > query in the rails apps to be sure to exclude those records (WHERE > > state NOT ''deleted). I would prefer that this is transparent and > > that the application doesn''t have to always add this filter but that > > it is automatically handled by ActionRecord. > > > > What is the best way to achieve this with Rails? Is there already > > native ActionRecord capability for this or perhaps a plugin > > available for this functionality? > > I think the canonical solution in Rails is acts_as_paranoid. > > -- fxn > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---