Skip to content

Instantly share code, notes, and snippets.

@keithpitt
Last active February 14, 2017 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithpitt/b4be9809e967f328655b95c3c4196254 to your computer and use it in GitHub Desktop.
Save keithpitt/b4be9809e967f328655b95c3c4196254 to your computer and use it in GitHub Desktop.
# Add this file to `spec/support/active_record_id_tracer.rb`
module ActiveRecordIDTracer
def insert(*args)
super(*args).tap do |returned_id|
Rails.logger.debug("\033[1m\033[33mActiveRecordIDTracer\033[0m #{klass.name} insert returned ID #{returned_id}")
end
end
end
ActiveRecord::Relation.prepend ActiveRecordIDTracer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment