From c4b29aa2a7488d2afb358cd85f873f9f3ea7a6cd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 29 Sep 2013 19:22:13 +0200 Subject: [PATCH] Log history values as strings. --- app/models/application_model.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 1339ce813..eeba7143d 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -506,7 +506,7 @@ log object create history, if configured - will be executed automatically def history_create return if !self.class.history_support_config -# puts self.changes.inspect + #puts 'create ' + self.changes.inspect self.history_log( 'created', self.created_by_id ) end @@ -530,8 +530,8 @@ log object update history with all updated attributes, if configured - will be e # new record also triggers update, so ignore new records changes = self.changes + #puts 'updated ' + self.changes.inspect return if changes['id'] && !changes['id'][0] - #puts 'updated' + self.changes.inspect # TODO: Swop it to config file later ignore_attributes = { @@ -554,6 +554,7 @@ log object update history with all updated attributes, if configured - will be e if attribute_name[-3,3] == '_id' attribute_name = attribute_name[ 0, attribute_name.length-3 ] end + value_id = [] if key.to_s[-3,3] == '_id' value_id[0] = value[0] @@ -583,12 +584,12 @@ log object update history with all updated attributes, if configured - will be e end data = { :history_attribute => attribute_name, - :value_from => value[0], - :value_to => value[1], + :value_from => value[0].to_s, + :value_to => value[1].to_s, :id_from => value_id[0], :id_to => value_id[1], } - #puts "HIST NEW " + data.inspect + #puts "HIST NEW #{self.class.to_s}.find(#{self.id}) #{data.inspect}" self.history_log( 'updated', self.updated_by_id, data ) } end