Skip to main content

How to use versions to see version history of app content using papertrail

Using papertrail, we can automatically save changes to a give model. Example app.rb' has_paper_trail if: Proc.new { |a| a.papertrailable? }, on: %i(update destroy), only: %i(content)`

To find the saved versions for a particular app: App.find(10126675).versions

To look at changed content: content = App.find(10126675).versions[1].object_changes['content'] keys = content[0].keys keys.each do |key| puts "Key: #{key}. was: #{content[0][key]}; now: #{content[1][key]}".blue if content[0][key] != content[1][key] end