Skip to content

Instantly share code, notes, and snippets.

@mgarriss
Created September 10, 2010 19:51
Show Gist options
  • Save mgarriss/574261 to your computer and use it in GitHub Desktop.
Save mgarriss/574261 to your computer and use it in GitHub Desktop.
def change_history(audits)
result = ''
unless audits.nil? || audits.empty?
result << '<h1>Change history</h1>'
audits.each do |audit|
result << "<p><b>Version #{audit.version} (#{audit.action.titleize}, #{audit.created_at.in_time_zone('America/Denver').to_s(:long)}):</b><br />"
result << '<ul>'
audit.changes.each do |attribute, delta|
if delta.is_a?(Array)
result << "<li>Changed #{attribute.titleize}: from '#{delta.first}' to '#{delta.last}'</li>"
else
result << "<li>Set #{attribute.titleize} to '#{delta}'</li>"
end
end
result << '</ul>'
end
result << '</p>'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment