lib/thoth/rails/model.rb in thoth-1.0.2 vs lib/thoth/rails/model.rb in thoth-2.0.0
- old
+ new
@@ -35,20 +35,24 @@
self.class.columns.map(&:name) - except_options.map(&:to_s)
else
self.class.thoth_options[:only]
end
- if only_options.empty? || !(only_options.map(&:to_s) & changes.keys).empty?
+ if only_options.empty? || !(only_options.map(&:to_s) & changed_attribute_names_to_save).empty?
thoth_log_model(:update)
end
end
def thoth_log_destroy
return unless self.class.thoth_options[:on].include?(:destroy)
thoth_log_model(:destroy)
end
def thoth_log_model(action)
- Thoth.logger.log("#{self.class.name} #{action}", changes: changes, attributes: attributes)
+ Thoth.logger.log("#{self.class.name} #{action}", changes: changes_to_log, attributes: attributes)
+ end
+
+ def changes_to_log
+ has_changes_to_save? ? changes_to_save : saved_changes
end
end
end