From e814239f1358985dec0002b3ebfd5bf3dde23e43 Mon Sep 17 00:00:00 2001
From: Per Cederqvist <ceder@lysator.liu.se>
Date: Sun, 29 Oct 2006 21:05:30 +0000
Subject: [PATCH] Allow the user to leave some saldos empty when using
 create_snapshot.  Blank saldos won't create any saldo rows.

---
 app/controllers/saldos_controller.rb | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/app/controllers/saldos_controller.rb b/app/controllers/saldos_controller.rb
index 784f14a..801845f 100644
--- a/app/controllers/saldos_controller.rb
+++ b/app/controllers/saldos_controller.rb
@@ -62,14 +62,16 @@ class SaldosController < ApplicationController
     ok = true
     @saldos = []
     (0...params[:saldos].to_i).each { |ix|
-      saldo = Saldo.new(params[:saldo][ix.to_s])
-      puts ix
-      puts params[:saldo][ix]
-      puts params[:saldo]
-      if not saldo.save
-        ok = false
+      if params[:saldo][ix.to_s][:amount] != ""
+        saldo = Saldo.new(params[:saldo][ix.to_s])
+        puts ix
+        puts params[:saldo][ix.to_s]
+        puts params[:saldo]
+        if not saldo.save
+          ok = false
+        end
+        @saldos << saldo
       end
-      @saldos << saldo
     }
     if ok
       flash[:notice] = 'Saldos were successfully created.'
-- 
GitLab