Skip to content

Instantly share code, notes, and snippets.

@keithpitt
Last active February 14, 2017 03:29

Revisions

  1. keithpitt revised this gist Feb 14, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions active_record_id_tracer.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Add this file to `spec/support/active_record_id_tracer.rb`

    module ActiveRecordIDTracer
    def insert(*args)
    super(*args).tap do |returned_id|
  2. keithpitt revised this gist Feb 14, 2017. No changes.
  3. keithpitt revised this gist Feb 14, 2017. No changes.
  4. keithpitt created this gist Feb 14, 2017.
    9 changes: 9 additions & 0 deletions active_record_id_tracer.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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