Comments (8)
Audited::Audit.audited_classes.each do |audited_class|
audited_class.auditing_enabled = false # or `true` to enable
end
works for me now
from audited.
One approached I've experimented with:
Audit.audited_classes.each do |audited_class|
audited_class.disable_auditing
end
Audit.audited_classes.each do |audited_class|
audited_class.enable_auditing
end
The problem then becomes WHEN to do this. If cache_classes is false, then doing this in the environment.rb or development.rb won't work because the classes aren't loaded yet for Audit.audited_classes to give us an accurate list.
from audited.
Here is another solution to this:
module CollectiveIdea::Acts::Audited::InstanceMethods
private
def write_audit(attrs)
self.audits.create attrs if auditing_enabled && Audit.auditing_enabled?
end
end
class Audit
@@auditing_enabled = true
def self.auditing_enabled?
@@auditing_enabled
end
def self.disable_auditing
@@auditing_enabled = false
end
def self.enable_auditing
@@auditing_enabled = true
end
end
This way you will be able to do Audit.disable_auditing
, and it will globally disable creation of any Audit objects until you do Audit.enable_auditing
again
I'll take no responsibility for what comes out of this though, and it was a five minute fix. It seems to work for me. Good luck.
from audited.
This would be a nice feature and would really help speed up testing.
from audited.
@Frost I took your idea and modified it slightly for my use case. I like what you came up with, but it needed some modification for version 3.0.
Gist is here: https://gist.github.com/4392334
from audited.
It seems the label 2.0.x is no longer valid https://github.com/collectiveidea/audited/blob/master/lib/audited/auditor.rb#L82 :-) Is there any chance for this feature to get in so can avoid hacking Audited gem internals in rake tasks where we don't won't it to audit changes?
from audited.
Thank you @desoleary. Looks like that solves/closes this issue! 👏
from audited.
Looks like that this issue has been finally solved in #426 . Great!
from audited.
Related Issues (20)
- Rails 7.1.beta.1 - DEPRECATION WARNING: Module.deprecate without a deprecator is deprecated HOT 1
- Exclude Audited Gem Log Entries from PostgreSQL Database Storage
- Encryption for audited_changes / disabling the FILTERED feature HOT 4
- Audits with line of code location HOT 1
- Different kinds of User. HOT 2
- Updating an enum field on audited record while updating nested resource with touch: true creates a double audit
- `#touch` on record results in `NoMethodError` HOT 1
- Conditionally turn off audits in tests
- Auditing models with a Composite Primary Key - possible? HOT 1
- Ignoring deleted_at/deleted_on attributes
- Support for batch creation of audits HOT 2
- Support for BigInt HOT 1
- How to ignore impersonated user ?
- Specify action
- Add YAML safe load documentation
- Gem is not saving auditable_id, auditable_type for User model
- When combining old audits, oldest value should be kept
- Preloading audits is ignored when accessing specific revision
- Testing the ActiveRecord version would allow to use audited without Rails. HOT 1
- Is this open? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audited.