Created
September 24, 2020 21:18
-
-
Save zdennis/6449361fb7ff243f0a2080966dfbdd5e to your computer and use it in GitHub Desktop.
Patch to revert a bugfix in Rails 5.2 ( https://github.com/rails/rails/commit/a84c76573fa776e377c087930dcbdc3a07eb8603 )
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
DisableSettingInverse.disabled = true | |
child = Child.new(parent_id: 12345) | |
parent = Parent.new | |
parent.children = [child] | |
child.parent_id # => 12345 | |
DisableSettingInverse.disabled = false |
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
module DisableSettingInverse | |
class << self | |
attr_accessor :disabled | |
end | |
def set_inverse_instance(record) | |
super unless DisableSettingInverse.disabled | |
end | |
end | |
ActiveRecord::Associations::CollectionAssociation.prepend DisableSettingInverse | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment