Forum: Ruby on Rails act_as_paranoid and model references

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Santiago E. (Guest)
on 2006-03-27 18:37
(Received via mailing list)
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?
Jonathan W. (Guest)
on 2006-03-29 17:59
(Received via mailing list)
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
Rick O. (Guest)
on 2006-03-29 19:37
(Received via mailing list)
On 3/29/06, Jonathan W. <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
Santiago E. (Guest)
on 2006-03-30 17:34
(Received via mailing list)
On 3/29/06, Rick O. <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
This topic is locked and can not be replied to.