From d1ec1e2681c4ac1af1b9ecb89c3a43ee8de6fa11 Mon Sep 17 00:00:00 2001
From: Robin Ward <robin.ward@gmail.com>
Date: Thu, 29 Jan 2015 17:17:32 -0500
Subject: [PATCH] Allow code to save custom fields without saving the attached
 object

---
 app/models/concerns/has_custom_fields.rb | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/app/models/concerns/has_custom_fields.rb b/app/models/concerns/has_custom_fields.rb
index 854dee20e..7b6876190 100644
--- a/app/models/concerns/has_custom_fields.rb
+++ b/app/models/concerns/has_custom_fields.rb
@@ -78,17 +78,6 @@ module HasCustomFields
     !@custom_fields || @custom_fields_orig == @custom_fields
   end
 
-  protected
-
-  def refresh_custom_fields_from_db
-    target = Hash.new
-    _custom_fields.pluck(:name,:value).each do |key, value|
-      self.class.append_custom_field(target, key, value)
-    end
-    @custom_fields_orig = target
-    @custom_fields = @custom_fields_orig.dup
-  end
-
   def save_custom_fields
     if !custom_fields_clean?
       dup = @custom_fields.dup
@@ -134,4 +123,16 @@ module HasCustomFields
       refresh_custom_fields_from_db
     end
   end
+
+  protected
+
+  def refresh_custom_fields_from_db
+    target = Hash.new
+    _custom_fields.pluck(:name,:value).each do |key, value|
+      self.class.append_custom_field(target, key, value)
+    end
+    @custom_fields_orig = target
+    @custom_fields = @custom_fields_orig.dup
+  end
+
 end