fix error where empty line causes server error

This commit is contained in:
Reinier Balt 2011-01-24 23:05:31 +01:00
parent 30983b6658
commit bf5e378301
2 changed files with 33 additions and 12 deletions

View file

@ -162,17 +162,19 @@ class TodosController < ApplicationController
@todos = []
params[:todo][:multiple_todos].split("\n").map do |line|
@todo = current_user.todos.build(
:description => line)
@todo.project_id = @project_id
@todo.context_id = @context_id
@saved = @todo.save
unless (@saved == false) || tag_list.blank?
@todo.tag_with(tag_list)
@todo.tags.reload
unless line.blank?
@todo = current_user.todos.build(
:description => line)
@todo.project_id = @project_id
@todo.context_id = @context_id
@saved = @todo.save
unless (@saved == false) || tag_list.blank?
@todo.tag_with(tag_list)
@todo.tags.reload
end
@todos << @todo
@not_done_todos << @todo if @new_context_created
end
@todos << @todo
@not_done_todos << @todo if @new_context_created
end
respond_to do |format|