Skip to content

Include deleted records in association #24

Description

@josal

Hi,

when I use Model.unscoped I have all the objects, deleted and not deleted ones, but if I want to have the same list but from an associated model, I've not been able to find the proper way to do it without monkeypatching the method.

For example, let's suppose: Post has many comments. Comment belongs_to :post. Now, Post.first.comments shows always the scoped list, but how can I get the unscoped list without monkeypatching the comments method in Post model? Yes, comments.unscoped works. But Comment.first.post is always searched with the scoped scope and if the Post have been deleted, the result is nil. How can I include the unscoped ones in this reverse association?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions