lib/active_metadata/persistence/history.rb in active_metadata-0.8.4 vs lib/active_metadata/persistence/history.rb in active_metadata-0.8.5
- old
+ new
@@ -7,10 +7,12 @@
module InstanceMethods
def save_history
return if ActiveMetadata.skip_history?
self.changes.each do |key, value|
+ # Do not go on in case if new and old values are nil
+ return if value.compact.empty?
next if ActiveMetadata::CONFIG['history_skip_fields'].include?(key)
ActiveMetadata::History.create! :value => value[1],:model_class => metadata_class, :model_id => metadata_id,:label => key.to_s, :created_by => current_user_id
invalidate_history_cache_for key.to_s
self.send(:send_notification, key, value[0], value[1], :history_message, current_user_id) unless skip_history_notification?
end
@@ -24,14 +26,14 @@
private
def invalidate_history_cache_for field
Rails.cache.delete history_cache_key(field)
- end
+ end
def fetch_histories_for field, order
ActiveMetadata::History.all(:conditions => {:model_class => metadata_class, :model_id => metadata_id,:label => field}, :order => order)
- end
+ end
end
end
\ No newline at end of file