Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ActiveRecord::Delegation prevent overriding existing methods
I discovered this while working on #47800 The bug is quite subtle. If you call `Model.all.delete(id)`, `all` is an `ActiveRecord::Relation` which does not respond to `delete`, so it delegates to `Model.delete` and generate that method in the `GeneratedRelationMethods` module. The problem however, is that `CollectionProxy` does define `delete`, so after that initial call, the `Model::ActiveRecord_CollectionProxy` subclass now has its `delete` method overridden, and now delegate to the model. Here I chose to keep that method generation caching, but I'm honestly not convinced it's really needed. I question how much of a hotspot these methods are, and we're busting method caches and generating a lot of code to save on a minor `method_missing` call. I think we should just remove that caching.
- Loading branch information
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters