Is it possible to configure PaperTrail gem to ignore attributes globally?

621 views Asked by At

The PaperTrail gem docs state that you can configure individual models to ignore some attributes -- This works great, but I want to skip all updated_at attributes (in every model). Is there a way to do this globally (in an initializer?). Something like PaperTrail.config.ignore = [:updated_at]

Related question: Is there a list of global configuration options for the PaperTrail gem?

1

There are 1 answers

1
Jared Beck On BEST ANSWER

Currently (January 2017) there is no global model configuration in PaperTrail. You could do this with a global constant.

# config/initializers/global_constants.rb
GLOBAL_PT_IGNORE = [:updated_at]

# app/models/foo.rb
has_paper_trail(ignore: GLOBAL_PT_IGNORE + [:banana])

# app/models/bar.rb
has_paper_trail(ignore: GLOBAL_PT_IGNORE + [:kiwi, :mango])