问题
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:
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])
来源:https://stackoverflow.com/questions/41548357/is-it-possible-to-configure-papertrail-gem-to-ignore-attributes-globally