Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include deleted records in association #24

Open
josal opened this issue Oct 22, 2014 · 0 comments
Open

Include deleted records in association #24

josal opened this issue Oct 22, 2014 · 0 comments

Comments

@josal
Copy link

josal commented Oct 22, 2014

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant