Ticket #46 (new defect)

Opened 7 months ago

better_nested_set keeps updated_at from getting updated

Reported by: rails Assigned to: jcm
Priority: major Milestone:
Component: doc Version: trunk
Keywords: Cc:

Description

Because better_nested_set overrides update, it does not cause the base.alias_method_chain to work in ActiveRecord? for timestamps.

I fixed it by adding the following code:

@@ -557,6 +557,12 @@
               "WHERE #{self.class.primary_key} = #{quote_value(id)}",
               "#{self.class.name} Update"
             )
+            #AGS: added so that it will update timestamps
+            if record_timestamps
+              t = self.class.default_timezone == :utc ? Time.now.utc : Time.now
+              write_attribute('updated_at', t) if respond_to?(:updated_at)
+              write_attribute('updated_on', t) if respond_to?(:updated_on)
+            end
           end
 
           # exclude the lft/rgt columns from update statements