From 6ed4053694788fb1c19720a1131704a90a25cf66 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 11 Sep 2018 02:20:50 -0500 Subject: [PATCH] don't save fields/categories when we don't need to --- app/models/concerns/has_attributes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index eafa81bc..be355057 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -23,7 +23,7 @@ module HasAttributes # Default new categories to the default icon category.icon = details[:icon] unless category.persisted? - category.save! if user + category.save! if user && category.new_record? category.attribute_fields << details[:attributes].map do |field| af_field = category.attribute_fields.with_deleted.find_or_initialize_by( label: field[:label], @@ -31,7 +31,7 @@ module HasAttributes user: user, field_type: field[:field_type].presence || "text_area" ) - af_field.save! if user + af_field.save! if user && af_field.new_record? af_field end if details.key?(:attributes)