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?
Hi,
when I use
Model.unscopedI 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:
Posthas many comments.Commentbelongs_to:post. Now,Post.first.commentsshows always thescopedlist, but how can I get theunscopedlist without monkeypatching thecommentsmethod inPostmodel? Yes,comments.unscopedworks. ButComment.first.postis always searched with thescopedscope and if the Post have been deleted, the result is nil. How can I include theunscopedones in this reverse association?