Commit 8b13992c authored by Eric Davis's avatar Eric Davis

Print any errors when saving the initial journal instead of aborting

parent 52b83da8
......@@ -42,14 +42,22 @@ class BuildInitialJournalsForActsAsJournalized < ActiveRecord::Migration
elsif o.respond_to?(:user)
new_journal.user = o.user
end
new_journal.save
new_journal.reload
if new_journal.save
new_journal.reload
# Backdate journal
if o.respond_to?(:created_at)
new_journal.update_attribute(:created_at, o.created_at)
elsif o.respond_to?(:created_on)
new_journal.update_attribute(:created_at, o.created_on)
# Backdate journal
if o.respond_to?(:created_at)
new_journal.update_attribute(:created_at, o.created_at)
elsif o.respond_to?(:created_on)
new_journal.update_attribute(:created_at, o.created_on)
end
else
if new_journal.errors.count == 1 && new_journal.errors.first[0] == "version"
# Skip, only error was from creating the initial journal for a record that already had one.
else
puts "ERROR: errors creating the initial journal for #{o.class.to_s}##{o.id.to_s}:"
puts " #{new_journal.errors.full_messages.inspect}"
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment