Created
October 15, 2011 06:15
-
-
Save armstrjare/1289136 to your computer and use it in GitHub Desktop.
Temporary monkeypatch to fix a bug with ActiveRecord::AutosaveAssociation until it's fixed upstream.
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 ActiveRecord | |
module AutosaveAssociationFix | |
private | |
def associated_records_to_validate_or_save(*) | |
# There exists a case (new_record) where the returned array is actually the internal collection array. | |
# Unfortunately, this now gets mutated when records are removed. This means use of mark_for_destruction | |
# (to prevent creation of built records) can result in some records not being iterated over (and | |
# consequently not saved) on creation. | |
super.try(:dup) | |
end | |
end | |
ActiveSupport::Deprecation.warn("Including Rails 3.1 AutosaveAssociation fix monkey patch. This should be removed when fixed in Rails.") | |
ActiveRecord::Base.send(:include, AutosaveAssociationFix) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment