Created
October 30, 2019 18:25
-
-
Save johnpmitsch/02268da2997fafb46ba3e2f625fd1f37 to your computer and use it in GitHub Desktop.
Debug audit assocation issue in rails
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
# Context: https://bugzilla.redhat.com/show_bug.cgi?id=1613391 | |
# Update activerecord-5.2.1/lib/active_record/associations/has_many_association.rb on line 105 to log which association is causing issues | |
def delete_records(records, method) | |
if method == :destroy | |
begin | |
records.each(&:destroy!) | |
rescue => e | |
logger = Logger.new('/tmp/rails.log') | |
logger.info(self.owner) | |
logger.info(records) | |
raise e | |
end | |
update_counter(-records.length) unless reflection.inverse_updates_counter_cache? | |
else | |
scope = self.scope.where(reflection.klass.primary_key => records) | |
update_counter(-delete_count(method, scope)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment