-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auditing of virtual attributes (e.g. tag_list) #1
Comments
I don’t know if this is possible. acts_as_audited depends on Active Record’s dirty tracking, which detects changes to attributes. I wouldn’t be opposed to adding this, if you could come up with a clean implementation. Another idea I had was to allow auditing of any arbitrary data with a record. For example, if I wanted to store the IP of the user. I haven’t come up with a good API for it yet, but here are a couple ideas: ```
|
Hm, after some investigation I think it would be better to tell other plugins (like acts_as_taggable etc.) to “make the model dirty”, so e.g. after setting tag_list to a new value, the “changed_attributes” hash should reflect this change. |
did anyone ever come up with a working solution to this? It's a problem I'm looking at right now |
I'm looking into the "dirty" method, but I'm wondering if it might affect partial_updates? |
I don't know of anyone that is working on this yet. |
what do you think of this? Rather than try to come up a generic API, you just add whatever you need to changed_methods hash. I changed self[attr] to send(attr), it didn't break any tests and I can't see that it would cause any problems. --- a/lib/acts_as_audited.rb
then I used this method in my class to audit the tag list audit tag changesdef set_tag_list_on_with_audit(context,new_list, tagger=nil) |
sorry about the formatting |
Doing some house cleaning and closing here. If you guys want to take a stab at this again, we're now using Rails 3 and maybe ActiveModel makes this easier to achieve. The contribution guidelines in the README have been updated to show the new branches and suggestions for pull requests. Thanks ! |
…cts_as_audited into nilakanta-after_audit_callback * 'after_audit_callback' of https://github.com/nilakanta/acts_as_audited: reverting the gemspec bump bumping the gem version adding a callback for after_audit actions [#1] It should be possible to use the same audits table with Rails 2 and 3 versions of the same app. Audits table should not raise ActiveRecord::DangerousAttributeError in Rails 3.0. Rename audits.changes to audits.audited_changes. adding support for an after_audit callback bump the version to 1.1.2.beta1 Version bump to 0.0.0 comments are essential only for specified attributes and only on specified validation_options require comment validations apply only if auditing is enabled
Got acts_as_taggable working correctly with this the around_audit callback like this:
|
@tquill I found that this doesn't work with the first version of an object. I also added
|
@tquill the solution you suggested is incomplete. It only works for The latter always returns the latest tags no matter what
|
… with Rails 2 and 3 versions of the same app. Audits table should not raise ActiveRecord::DangerousAttributeError in Rails 3.0. Rename audits.changes to audits.audited_changes.
Rename audits.changes to audits.audited_changes
Join Aliasing
Use RequestStore instead of Thread.current for thread-safe requests.
I would like to audit virtual attributes, which are not stored as columns in the same table. Think about a “tag_list” managed by acts_as_taggable_on. This virtual attributes are stored elsewhere, but the changes should be audited in the owner model.
Perhaps this could be configured by an additional option like :add in addition to :except.
The text was updated successfully, but these errors were encountered: