# Act\_as\_paranoid and model references

**URL:** <https://www.ruby-forum.com/t/act-as-paranoid-and-model-references/56043>\
**Category:** Rails\
**Created:** [March 27, 2006, 4:37pm UTC](https://www.ruby-forum.com/t/act-as-paranoid-and-model-references/56043 "2006-03-27T16:37:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santiago\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/91b2a8/32.png) [@Santiago\_E](https://www.ruby-forum.com/u/Santiago_E)\
**Post date:** [March 27, 2006, 4:37pm UTC](https://www.ruby-forum.com/t/act-as-paranoid-and-model-references/56043/1 "2006-03-27T16:37:01Z")

</div>

I’m using act\_as\_paranoid plugin for most of my models. One of the  
reasons was that I didn’t want to break references between objects  
after I “deleted” an object. One of the cases was to know which user  
modified something even after I deleted the user.

My problem now is that I cannot access the user after it was deleted  
if I use the :has\_and\_belongs\_to :user relationship.

Is there any way to override act\_as\_paranoid behavior only to access  
relationships in some cases even if the object is soft deleted?

---

<div class="post-metadata">

**Author:** ![Santiago\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/91b2a8/32.png) [@Santiago\_E](https://www.ruby-forum.com/u/Santiago_E)\
**Post date:** [March 29, 2006, 3:59pm UTC](https://www.ruby-forum.com/t/act-as-paranoid-and-model-references/56043/2 "2006-03-29T15:59:26Z")

</div>

Santiago E. wrote:

> I’m using act\_as\_paranoid plugin for most of my models. One of the  
> reasons was that I didn’t want to break references between objects  
> after I “deleted” an object. One of the cases was to know which user  
> modified something even after I deleted the user.
> 
> My problem now is that I cannot access the user after it was deleted  
> if I use the :has\_and\_belongs\_to :user relationship.
> 
> Is there any way to override act\_as\_paranoid behavior only to access  
> relationships in some cases even if the object is soft deleted?

user.things.find(:all, :with\_deleted =\> true)

Jonathan

---

<div class="post-metadata">

**Author:** ![Santiago\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/91b2a8/32.png) [@Santiago\_E](https://www.ruby-forum.com/u/Santiago_E)\
**Post date:** [March 29, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/act-as-paranoid-and-model-references/56043/3 "2006-03-29T17:37:22Z")

</div>

On 3/29/06, Jonathan W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > relationships in some cases even if the object is soft deleted?
> 
> user.things.find(:all, :with\_deleted =\> true)

That isn’t required any more. Try this:

user.things.find\_with\_deleted(:all)

–  
Rick O.  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![Santiago\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/91b2a8/32.png) [@Santiago\_E](https://www.ruby-forum.com/u/Santiago_E)\
**Post date:** [March 30, 2006, 3:34pm UTC](https://www.ruby-forum.com/t/act-as-paranoid-and-model-references/56043/4 "2006-03-30T15:34:09Z")

</div>

On 3/29/06, Rick O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > Is there any way to override act\_as\_paranoid behavior only to access  
> > > relationships in some cases even if the object is soft deleted?
> > 
> > user.things.find(:all, :with\_deleted =\> true)
> 
> That isn’t required any more. Try this:
> 
> user.things.find\_with\_deleted(:all)

That’s fine as you are going from User to Things. What if you go the  
other way?

What I mean is … I delete a user whose model has act\_as\_paranoid.  
“Things” doesn’t get deleted, on purpose, if you delete a user because  
the relationship is only to know who created that “thing”. I have an  
object type Thing that I want to show in a page and I want to find out  
who created it, but the user was soft deleted.

How can I do that?

Santiago
