lib/freeform/form.rb in freeform-2.0.2 vs lib/freeform/form.rb in freeform-2.0.3

- old
+ new

@@ -37,10 +37,11 @@ def save(*args) if valid? before_save persist_models + reload_models after_save true else false end @@ -77,8 +78,17 @@ def persist_models models.each { |m| m.destroy if m.marked_for_destruction? } # We skip validation for underlying models, since we've already run our validation. models.each { |m| m.save(:validate => false) unless m.marked_for_destruction? } + end + + #TODO: Come up with a test that can validate this behavior + def reload_models + models.each do |m| + unless m.marked_for_destruction? + m.reload if m.respond_to?(:reload) + end + end end end end