一些‘选择’
你可以让paper_trail ‘忽略’ 一些改动,不记录它,比如 ‘忽略’ create :
class Article < ActiveRecord::Base
has_paper_trail :on => [:update, :destroy] # 通过 on 选项
end
或者 ‘何时’ 才生成一个新版本 ‘version’
class Translation < ActiveRecord::Base
# 通过 if 或 unless 选项
has_paper_trail :if => Proc.new { |t| t.language_code == 'US' },
:unless => Proc.new { |t| t.type == 'DRAFT' }
end
再或者是 ‘忽略’ 一些不想 ‘跟踪’ 的属性:
class Article < ActiveRecord::Base
has_paper_trail :ignore => [:title, :rating] # 通过 ignore
end
与上面的 ignore 相反,你可以‘只跟踪’自己 ‘指定’ 的属性
class Article < ActiveRecord::Base
has_paper_trail :only => [:title] # 通过 only
end
从一开始就 ‘忽略’ 一些 属性(区别于上面的各个‘选项’)
class Article < ActiveRecord::Base
has_paper_trail :skip => [:file_upload] # 用 skip
end