Soft Deletes

1 view
Skip to first unread message

Mike Gehard

unread,
Nov 20, 2009, 11:16:43 AM11/20/09
to Ruby on Rails: Talk
Hello all,

I am wondering how people here are handling soft deletes in Rails.
I've need a couple of gems/plugins that seem to handle this but from
what I gather development has stopped on them.

All I need to do right now is mark something as deleted in the
DB...nothing fancy.

I'm thinking that the simple addition of a deleted_at column, some
named scopes (maybe even a default scope) and a handler on delete to
set the deleted_at column and prevent the actual DB delete will do the
trick. Any gotchas that I need to watch out for?

Thanks in advance.
Mike
Message has been deleted

bill walton

unread,
Nov 23, 2009, 12:12:39 PM11/23/09
to rubyonra...@googlegroups.com
Hi Mike,

On Mon, 2009-11-23 at 07:45 -0800, Mike Gehard wrote:
> I'm thinking that the simple addition of a deleted_at column, some
> named scopes (maybe even a default scope) and a handler on delete to
> set the deleted_at column and prevent the actual DB delete will do the
> trick. Any gotchas that I need to watch out for?

Sounds entirely reasonable.

Best regards,
Bill

Chris Drappier

unread,
Nov 23, 2009, 12:21:29 PM11/23/09
to rubyonra...@googlegroups.com
we do this in conjunction with versioning our records, makes it very easy to pull associations through history. You're definitely on the right track.


--

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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.



stuart.coyle

unread,
Nov 23, 2009, 4:59:14 PM11/23/09
to Ruby on Rails: Talk
I've used the acts_as_paranoid plugin successfully for this.

On Nov 24, 3:21 am, Chris Drappier <chris.drapp...@gmail.com> wrote:
> we do this in conjunction with versioning our records, makes it very easy to
> pull associations through history. You're definitely on the right track.
>
> On Mon, Nov 23, 2009 at 11:12 AM, bill walton <bwalton...@gmail.com> wrote:
> > Hi Mike,
>
> > On Mon, 2009-11-23 at 07:45 -0800, Mike Gehard wrote:
> > > I'm thinking that the simple addition of a deleted_at column, some
> > > named scopes (maybe even a default scope) and a handler on delete to
> > > set the deleted_at column and prevent the actual DB delete will do the
> > > trick.  Any gotchas that I need to watch out for?
>
> > Sounds entirely reasonable.
>
> > Best regards,
> > Bill
>
> > --
>
> > 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 rubyonra...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-ta...@googlegroups.com<rubyonrails-talk%2Bunsu...@googlegroups.com>
> > .

Lee Smith

unread,
Nov 24, 2009, 5:46:32 PM11/24/09
to Ruby on Rails: Talk
Mike,

I've implemented exactly what you're talking about, sans gems/
plugins. I starting down that road on deciding which plugin to use
but the more I thought about it, the more I realized I didn't need a
plugin...my needs were pretty simple. The problem I had with the
plugins was how they changed your AR finders behind the scenes. I
implemented my own named scopes and it works fine for me.

Mike Gehard

unread,
Nov 24, 2009, 6:04:43 PM11/24/09
to Ruby on Rails: Talk
Thanks all...I decided to forgoe the plugins/gems because the authors
of both of the recommended ones (acts_as_paranoid and is_paranoid)
have both decided that named scopes are the way to go for this.

Joshua Partogi

unread,
Nov 24, 2009, 7:34:20 PM11/24/09
to rubyonra...@googlegroups.com
On Nov 21, 3:16 am, Mike Gehard <m...@samyamatech.com> wrote:
> Hello all,
>
> I am wondering how people here are handling soft deletes in Rails.
> I've need a couple of gems/plugins that seem to handle this but from
> what I gather development has stopped on them.
>
> All I need to do right now is mark something as deleted in the
> DB...nothing fancy.
>
> I'm thinking that the simple addition of a deleted_at column, some
> named scopes (maybe even a default scope) and a handler on delete to
> set the deleted_at column and prevent the actual DB delete will do the
> trick. Any gotchas that I need to watch out for?
>
> Thanks in advance.
> Mike

I'm sorry to ask you back. But I'm interested with this too. Is
deleted_at handled by rails or your application?


Kind regards,

--
Certified Scrum Master
http://blog.scrum8.com | http://jobs.scrum8.com | http://twitter.com/scrum8
Reply all
Reply to author
Forward
0 new messages