-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow accessing deleted associations #3
Conversation
This used to be such a nice and simple library… Before going too far with this, please make sure that it works on #2 as well. |
Fucking edge cases... We're trying to avoid having to merge this in. |
@dasch could I convince you to resurrect this for: https://zendesk.atlassian.net/browse/HC-2710? @vkmita has a different approach as well, here: #4 |
Hah I remember hacking that. It was fun. |
87fbfc8
to
7032179
Compare
Adds a `with_deleted_associations` method that returns the object in a wrapper that checks all method calls. Those that correspond to associations are modified such that deleted associated records are included in the result.
7032179
to
698ea2b
Compare
|
||
def method_missing(name, *args, &block) | ||
delegate_to_record(name) { @record.public_send(name, *args, &block) } | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢 😿 😢 😿 😢 😿
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As recently as yesterday I ran into problems because of meta magic like this in Dynamic Content. Basically breaking ActiveModel::AttributeMethods and ActiveRecord::AttributeMethods reflection because we catch methods first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a war story.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if DC started using BasicObject those issues would go away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have my share of scar tissue.
@dasch why aren't you using |
With some reluctance: 👍 I really wish we weren't unwrapping (through wrapping) our default scopes. Maybe this should be hard-coded at the model layer. Calling extend on instances is no longer prohibitive, due to improvements on GC. Yadayada. |
👍 |
Allow accessing deleted associations
Adds a
with_deleted_associations
method that returns the object in a wrapper that checks all method calls. Those that correspond to associations are modified such that deleted associated records are included in the result.@bastien please review.