{"id":16014886,"url":"https://github.com/thheller/auditor","last_synced_at":"2025-10-17T23:51:29.254Z","repository":{"id":1402683,"uuid":"1439579","full_name":"thheller/auditor","owner":"thheller","description":"Audit Reports for your Models","archived":false,"fork":false,"pushed_at":"2011-08-19T09:44:51.000Z","size":176,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T11:11:43.181Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ucla/mwf","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thheller.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":"auditor.gemspec","citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-04T14:16:10.000Z","updated_at":"2014-03-31T01:31:24.000Z","dependencies_parsed_at":"2022-07-07T11:31:39.960Z","dependency_job_id":null,"html_url":"https://github.com/thheller/auditor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Fauditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Fauditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Fauditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thheller%2Fauditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thheller","download_url":"https://codeload.github.com/thheller/auditor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280181,"owners_count":20912965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T15:05:26.084Z","updated_at":"2025-10-17T23:51:29.194Z","avatar_url":"https://github.com/thheller.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Auditor\n\nRecord Model changes with ease.\n\nYou wish, I use this in one of my projects and wanted to use\nit in another, so this extraction came to be.\n\nDont use if you are not me.\n\nOnly records changes happening inside an Audit.process block,\nthere is a RackApp middleware to include to record any changes\ntriggered by any http request.\n\n= Usage\n\nRails3:\n\nconfig/application.rb\n\n  config.middleware.use '::Auditor::RackApp'\n\nany model that should record changes:\n\n  class Membership \u003c ActiveRecord::Base\n    include ::Auditor::Callbacks\n\n  end\n\nSave some report info?\n\n  class ApplicationController \u003c ...\n\n    before_filter :set_audit_infos\n\n    def set_audit_infos\n      Auditor.current do |audit|\n        audit.info[:method] = request.method\n        audit.info[:ip] = request.ip\n        audit.info[:referer] = request.referer\n        audit.user = current_user\n      end\n    \n      true\n    end\n  end\n\nUse in background daemons?\n\n  require 'socket' # not required, but i like hostnames\n\n  SomeModel.where('expires_at \u003c ?', Time.now).each do |it|\n    Audit.process do |audit|\n      audit.info[:pid] = Process.pid\n      audit.info[:hostname] = Socket.gethostname\n\n      it.expired!\n    end\n  end\n\n\n= Migration\n\nActiveRecord Models:\n\nAuditor::AuditReport\nAuditor::AuditChanges\n\n  class CreateAuditTables \u003c ActiveRecord::Migration\n    def self.up\n      create_table :audit_reports do |t|\n        t.string :uuid, :null =\u003e false, :length =\u003e 32\n\n        t.string :user_type\n        t.integer :user_id\n\n        t.text :info\n        t.integer :num_changes, :null =\u003e false\n\n        t.boolean :success, :null =\u003e false\n\n        t.string :error\n        t.text :error_message\n        t.text :error_detail\n\n        t.timestamp :began_at, :null =\u003e false\n        t.timestamp :finished_at, :null =\u003e false\n      end\n\n      create_table :audit_changes do |t|\n        t.integer :audit_report_id, :null =\u003e false\n        \n        t.string :model_type, :null =\u003e false\n        t.integer :model_id, :null =\u003e false\n\n        t.string :action, :null =\u003e false\n\n        t.text :audited_changes\n        \n        t.timestamp :created_at\n      end\n    end\n\n    def self.down\n    end\n  end\n\n\nThis project rocks anyways and uses MIT-LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthheller%2Fauditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthheller%2Fauditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthheller%2Fauditor/lists"}