myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [1885] branches/event_logging/vendor/plugins/acts


From: noreply
Subject: [myexperiment-hackers] [1885] branches/event_logging/vendor/plugins/acts_as_activity_logged/lib/ acts_as_activity_logged.rb: Explicitly switch on timestamping for ActiveRecord within ActivityLog.
Date: Fri, 24 Oct 2008 11:47:41 -0400 (EDT)

Revision
1885
Author
alekses6
Date
2008-10-24 11:47:40 -0400 (Fri, 24 Oct 2008)

Log Message

Explicitly switch on timestamping for ActiveRecord within ActivityLog. Fix: objects that have created_at / updated_at fields set to NULL are now logged properly.

Modified Paths

Diff

Modified: branches/event_logging/vendor/plugins/acts_as_activity_logged/lib/acts_as_activity_logged.rb (1884 => 1885)


--- branches/event_logging/vendor/plugins/acts_as_activity_logged/lib/acts_as_activity_logged.rb	2008-10-24 10:42:22 UTC (rev 1884)
+++ branches/event_logging/vendor/plugins/acts_as_activity_logged/lib/acts_as_activity_logged.rb	2008-10-24 15:47:40 UTC (rev 1885)
@@ -130,9 +130,13 @@
         # the object does not have a created_at attribute this switch will be ignored
         def write_activity_log(action = ""
           begin
+            # explicitly switch on timestamping for event log
+            previous_record_timestamps = ActivityLog.record_timestamps
+            ActivityLog.record_timestamps = true
+            
             # make sure that no logging is done within :delay_after_create time;
             # if no waiting required && if the filtering not required, write the log straight away
-            if (self.respond_to?(:created_at) && Time.now > self.delay_after_create.since(self.created_at)) || action == :create
+            if (self.respond_to?(:created_at) && !self.created_at.nil? && Time.now > self.delay_after_create.since(self.created_at)) || action == :create || self.created_at.nil?
               write_log = (self.check_log_allowed ? self.log_allowed(action.to_s) : true)
               if write_log
                 set_culprit
@@ -141,6 +145,8 @@
                 log_entry.save
               end
             end
+            
+            ActivityLog.record_timestamps = previous_record_timestamps
           rescue Exception => e
             # something went wrong - exception was thrown
             al = ActivityLog.new(:action ="" action.to_s, :activity_loggable => self)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]