Skip to content

Instantly share code, notes, and snippets.

@antarr
Last active July 31, 2019 17:55
Show Gist options
  • Save antarr/f0115be07391b4c0a4de2b0d314eea0f to your computer and use it in GitHub Desktop.
Save antarr/f0115be07391b4c0a4de2b0d314eea0f to your computer and use it in GitHub Desktop.
Active Admin Version Panel
# lib/ext/activeadmin.rb
module ActiveAdminPaperTrailDetails
def versions
panel 'Versions', class: 'versions' do
table_for resource.versions.order :created_at do
column(:whodunnit) { |v| auto_link User.find_by(id: v.whodunnit) }
column :event
column 'When', :created_at
column 'Changes' do |v|
attributes_table_for v.changeset.to_a do
row(:attribute) { |attr, _| attr }
row(:before) { |_, (before, _)| before }
row(:after) { |_, (_, after)| after }
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment