Skip to content

Instantly share code, notes, and snippets.

@dmitry
Created May 21, 2014 22:43
Show Gist options
  • Save dmitry/b94860e44516e417f6f4 to your computer and use it in GitHub Desktop.
Save dmitry/b94860e44516e417f6f4 to your computer and use it in GitHub Desktop.

Revisions

  1. dmitry created this gist May 21, 2014.
    17 changes: 17 additions & 0 deletions paper_trail.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    ActiveRecord::Base.module_eval do
    class << self
    def inherited_with_paper_trail(subclass)
    skip_models = %w(schema_migrations versions)

    inherited_without_paper_trail(subclass)

    table_name = subclass.table_name

    if !skip_models.include?(table_name) && table_name.present?
    subclass.send(:has_paper_trail)
    end
    end

    alias_method_chain :inherited, :paper_trail
    end
    end