Giter VIP home page Giter VIP logo

auditor's People

Contributors

ancorgs avatar jclark42796 avatar kunklejr avatar srfarley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

auditor's Issues

Add ability to audit on an ancestor

Consider the following relationships

worksheet has_one balance_sheet
balance_sheet has_many line_items
line_item has_many line_item_details

In my case, owner is the worksheet. So for each audit record, I need to identify a worksheet as the owner. A worksheet has a balance_sheet. For the balance_sheet I can audit "on" worksheet and this works fine. But a balance_sheet can have multiple line_items and I'm auditing line_item changes (as well as line_item_details). I need line_item audits to have an owner of worksheet, not balance_sheet. I don't have a direct relationship from line_item to worksheet. So I get the "parent" of line_item which is the balance_sheet. Then balance_sheet gets its parent, worksheet. This is the last model, so it is the owner.

This code would be on line_item_detail
audit!(:create, :update, :destroy, :on => [:line_item, :balance_sheet, :worksheet])

This code would be on line_item
audit!(:create, :update, :destroy, :on => [:balance_sheet, :worksheet])

This code would be on balance_sheet
audit!(:create, :update, :destroy, :on => :worksheet)

New Composite Index Needed

To address some performance issues we saw when the AUDITS table grew to around 300K rows we had to add a new composite index to speed up the query for the max version based on the auditable_id and auditable_type.

add_index  "audits", ["auditable_id", "auditable_type", "version"], :name => "auditable_index"

save audited_changes with data on destroy

I'm not sure if this is by design, but currently when I have audit(:destroy) on a model, it adds the record to the Audit table however the audited_changes field is nil. Would it be possible make it behave similar to :create? So it would have "name=>['Company Name', nil]" in the audited_changes field, similar to how it has "name=>[nil, 'Company Name']" for :create.

Thanks,
Michael

object other than user

Hello,

Is there an easy way to set the primary object of Auditor as something other than User? My app uses an object called Account, rather than User, and so current_user is current_account, user_id is account_id, etc.

Thanks for the gem!
George

Associate Audit Records with an Owner

Add a required polymorphic owner field to all audit records. This provides the ability to associate an audit record with a different model. This is useful for models that belong_to another model, providing a way to group all audit records associated with a parent.

"ORDER BY version, created_at" is automatically and always appended to database query

I am not sure if this is intended behavior. What I found is that "ORDER BY version, created_at" is always appended to database query generated by ActiveRecord. For example, if I do Audit.scoped.limit(20) in "rails c" window, without specifying any ordering criteria, the following SQL command is issued.

irb(main):001:0> Audit.scoped.limit(20)
Audit Load (1.2ms) SELECT "audits".* FROM "audits" ORDER BY version, created_at LIMIT 20

This is a bit surprising and caused some trouble. I would like to show audit records in absolute created_at order, ignoring "version".

I am using Rails 3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.