# Re-tasking destroy contoller action...is this bad practice?

**URL:** <https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002>\
**Category:** Rails\
**Created:** [October 27, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002 "2009-10-27T20:15:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolmenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolmenu](https://www.ruby-forum.com/u/coolmenu)\
**Post date:** [October 27, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002/1 "2009-10-27T20:15:40Z")

</div>

I’m trying to get some opinions on a design I’m floating (“rails way”  
or not?). Say I’ve got an Author model in my Blog application and I  
want my administrators to be able to disable authors. I don’t want to  
delete authors because this would cause data integrity issues  
(orphaned Author foreign key in the Post model). So my plan is to re-  
task the destroy method of the AuthorsContoller to allow an  
administrator to set a disabled\_at timestamp on an Author instead of  
actually deleting him.

What are the disadvantages to this design? One of the advantages to  
this design that I see is that I don’t have to declare a new  
controller method in my routes…it just fits into the REST design as  
is, no? Thanks for any advice.

---

<div class="post-metadata">

**Author:** ![coolmenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolmenu](https://www.ruby-forum.com/u/coolmenu)\
**Post date:** [October 27, 2009, 8:22pm UTC](https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002/2 "2009-10-27T20:22:35Z")

</div>

Lee S. wrote:

> I’m trying to get some opinions on a design I’m floating (“rails way”  
> or not?). Say I’ve got an Author model in my Blog application and I  
> want my administrators to be able to disable authors. I don’t want to  
> delete authors because this would cause data integrity issues  
> (orphaned Author foreign key in the Post model). So my plan is to re-  
> task the destroy method of the AuthorsContoller to allow an  
> administrator to set a disabled\_at timestamp on an Author instead of  
> actually deleting him.

You might want to do this by overriding Author#destroy instead, as  
acts\_as\_paranoid does. That should make things a bit more airtight.

> What are the disadvantages to this design? One of the advantages to  
> this design that I see is that I don’t have to declare a new  
> controller method in my routes…it just fits into the REST design as  
> is, no? Thanks for any advice.

Seems OK to me. REST is about conceptual naming, not your  
implementation.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![coolmenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolmenu](https://www.ruby-forum.com/u/coolmenu)\
**Post date:** [October 27, 2009, 8:56pm UTC](https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002/3 "2009-10-27T20:56:39Z")

</div>

Ah, so simply redefining the destroy method in the model accomplishes  
this? Is it just another public method? I don’t think I’ve ever  
overridden an activerecord method before…

---

<div class="post-metadata">

**Author:** ![coolmenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolmenu](https://www.ruby-forum.com/u/coolmenu)\
**Post date:** [October 27, 2009, 10:20pm UTC](https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002/4 "2009-10-27T22:20:45Z")

</div>

Lee S. wrote:

> Ah, so simply redefining the destroy method in the model accomplishes  
> this?

I would think so.

> Is it just another public method?

Yes.

> I don’t think I’ve ever  
> overridden an activerecord method before…

It might actually be better to use alias\_method\_chain, now that I think  
about it.

Or just install acts\_as\_paranoid.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![coolmenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolmenu](https://www.ruby-forum.com/u/coolmenu)\
**Post date:** [October 28, 2009, 5:43am UTC](https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002/5 "2009-10-28T05:43:34Z")

</div>

Yeah, I started to install acts\_as\_paranoid but I read that it’s not  
really updated anymore and may not even work with newer versions of  
Rails? I also looked at a revamped version of acts\_as\_paranoid called  
is\_paranoid that is supposed to use named\_scopes but now it looks like  
it has been abandoned by it’s author.

Which led me to roll my own…

---

<div class="post-metadata">

**Author:** ![coolmenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolmenu](https://www.ruby-forum.com/u/coolmenu)\
**Post date:** [October 28, 2009, 1:47pm UTC](https://www.ruby-forum.com/t/re-tasking-destroy-contoller-action-is-this-bad-practice/178002/6 "2009-10-28T13:47:24Z")

</div>

Lee S. wrote:

> Yeah, I started to install acts\_as\_paranoid but I read that it’s not  
> really updated anymore and may not even work with newer versions of  
> Rails?

Huh? The repository on Github was last updated in April 2009.

> I also looked at a revamped version of acts\_as\_paranoid called  
> is\_paranoid that is supposed to use named\_scopes but now it looks like  
> it has been abandoned by it’s author.
> 
> Which led me to roll my own…

I’ve never used acts\_as\_paranoid, but I think many people still use it,  
and the last update is recent enough that I assume it would work with  
Rails 2.3.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
