#196 ✓hold
Priit Tamboom

Soft delete with undo using STI?

Reported by Priit Tamboom | January 19th, 2009 @ 10:54 AM

Sven: Why do we need 3 models each? We don't have a concept of soft-deletes in adva-cms so far. If we want it, why not just set a deleted_at timestamp instead of using STI (seems a bit heavyweight)? Suggestion: remove this functionality for now.

Priit: I got requirement that user can undo issue/newsletter deletions.

I know option to use deleted_at but in my experience it looks simple only first but in reality it's a bit messy and bites later on because now everybody have to filter out deleted_at always when touching the model. With STI I have clean main model and dedicated deleted model with own separate logic and it plays out much cleaner in my opinion.

Some issues:

  • I have always deleted_at filter out manually ala Issue.find(:all, condition etc) or using named_scope "not_deleted" etc.
  • When I use named_scope or default_scope in Rails 2.3 then it still does not play nice at current Rails implementation. Perhaps it will, but not at the moment.
  • When I use STI I get dedicated model and dedicated deleted model with it's own logic.

Suggestion: I would not want to change it with Rails 2.2 because it is missing default_scope at the moment. Let's review it again when we use Rails 2.3 with default_scope method. However, I agree with Eric Andreson negative comment from http://ryandaigle.com/articles/2... about default scope does not play nice with current Rails implementation.

Comments and changes to this ticket

  • Priit Tamboom

    Priit Tamboom January 19th, 2009 @ 11:03 AM

    • State changed from “new” to “hold”
    • Assigned user changed from “Priit Tamboom” to “Sven Fuchs”
  • Sven Fuchs

    Sven Fuchs January 22nd, 2009 @ 12:13 AM

    Hmmm, I'm not sure. acts_as_paranoid always worked fine for me. And the newsletter/issue domain model is not that complicated.

    But I think we should reconsider that soft-delete requirement. Either we should soft-delete everything in adva-cms (at least contents and similar models) or none of them.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<p>Cutting edge cms, blog, wiki, forum ... plattform.</p>

<p>Find the code on <a href="http://github.com/svenfuchs/adva_cms/tree/master">GitHub: adva cms</a></p>

<p>Part of the business application framework <a href="http://www.advabest.org/">adva best</a>.</p>

People watching this ticket

Pages