是否可以将PaperTrail gem配置为全局忽略属性?

时间:2017-01-09 12:43:04

标签: paper-trail-gem

您可以将单个模型配置为PaperTrail gem docsignore some attributes状态 - 这很有用,但我想跳过所有updated_at属性(在每个模型中)。有没有办法全局(在初始化器中?)。像PaperTrail.config.ignore = [:updated_at]

之类的东西
  

相关问题:Is there a list of global configuration options for the PaperTrail gem?

1 个答案:

答案 0 :(得分:0)

目前(2017年1月)PaperTrail中没有全局模型配置。你可以用全局常量来做到这一点。

# 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])
相关问题