Improved debugging info.

This commit is contained in:
Martin Edenhofer 2012-11-07 16:10:24 +01:00
parent 2730b8e4a2
commit 4d448dda8a

View file

@ -3,7 +3,7 @@ class HistoryObserver < ActiveRecord::Observer
observe :ticket, :user, 'ticket::_article' observe :ticket, :user, 'ticket::_article'
def after_create(record) def after_create(record)
puts 'HISTORY OBSERVER, object created !!!!' + record.class.name puts "HISTORY OBSERVER, object created #{ record.class.name }(#{ record.id })"
# puts record.inspect # puts record.inspect
related_o_id = nil related_o_id = nil
related_history_object_id = nil related_history_object_id = nil
@ -22,7 +22,7 @@ class HistoryObserver < ActiveRecord::Observer
end end
def before_update(record) def before_update(record)
puts 'before_update' # puts 'before_update'
current = record.class.find(record.id) current = record.class.find(record.id)
# do not send anything if nothing has changed # do not send anything if nothing has changed
@ -30,7 +30,7 @@ class HistoryObserver < ActiveRecord::Observer
return return
end end
puts 'HISTORY OBSERVER object will be updated!!!!' + record.class.name puts "HISTORY OBSERVER object will be updated #{ record.class.name.to_s}(#{ current.id.to_s })"
# puts 'current' # puts 'current'
# puts current.inspect # puts current.inspect
# puts 'record' # puts 'record'
@ -38,8 +38,7 @@ class HistoryObserver < ActiveRecord::Observer
diff = differences_from?(current, record) diff = differences_from?(current, record)
puts ' DIFF' puts ' DIFF'
puts diff.inspect puts ' ' + diff.inspect
puts 'CURRENT O_ID ' + current.id.to_s
puts ' CURRENT USER ID ' + current_user_id.to_s puts ' CURRENT USER ID ' + current_user_id.to_s
map = { map = {
@ -67,7 +66,7 @@ class HistoryObserver < ActiveRecord::Observer
next if key.to_s == 'created_at' next if key.to_s == 'created_at'
next if key.to_s == 'updated_at' next if key.to_s == 'updated_at'
puts "#{key} is #{value_ids.inspect}" puts " CHANGED: #{key} is #{value_ids.inspect}"
# check if diff are ids, if yes do lookup # check if diff are ids, if yes do lookup
if value_ids[0].to_s == value_ids[1].to_s if value_ids[0].to_s == value_ids[1].to_s