From 9ae1e69bd65140c9c1238cfff7e9e131735f7452 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 20 Apr 2013 12:35:54 +0200 Subject: [PATCH] Improved auto fill of created_by_id and updated_by_id. --- app/models/application_model.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 1f36e4975..a9c8e314d 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -40,12 +40,12 @@ class ApplicationModel < ActiveRecord::Base data end - + # set created_by_id & updated_by_id if not given based on UserInfo def fill_up_user_create if self.class.column_names.include? 'updated_by_id' if UserInfo.current_user_id if self.updated_by_id && self.updated_by_id != UserInfo.current_user_id - raise "WARNING: create - self.updated_by_id is different: #{self.updated_by_id.to_s}/#{UserInfo.current_user_id.to_s}" + puts "NOTICE create - self.updated_by_id is different: #{self.updated_by_id.to_s}/#{UserInfo.current_user_id.to_s}" end self.updated_by_id = UserInfo.current_user_id end @@ -53,18 +53,17 @@ class ApplicationModel < ActiveRecord::Base if self.class.column_names.include? 'created_by_id' if UserInfo.current_user_id if self.created_by_id && self.created_by_id != UserInfo.current_user_id - raise "WARNING: create - self.created_by_id is different: #{self.created_by_id.to_s}/#{UserInfo.current_user_id.to_s}" + puts "NOTICE create - self.created_by_id is different: #{self.created_by_id.to_s}/#{UserInfo.current_user_id.to_s}" end self.created_by_id = UserInfo.current_user_id end end end + + # set updated_by_id if not given based on UserInfo def fill_up_user_update return if !self.class.column_names.include? 'updated_by_id' if UserInfo.current_user_id -# if self.updated_by_id && self.updated_by_id != UserInfo.current_user_id -# raise "WARNING: update - self.updated_by_id is different: #{self.updated_by_id.to_s}/#{UserInfo.current_user_id.to_s}" -# end self.updated_by_id = UserInfo.current_user_id end end