From c90bf645f51383ffb7bf2e3427b3e4c4672580f3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 17 May 2013 18:18:06 +0000 Subject: Fixed that submitting the form without selecting a value may raise raises an error with SQLServer (#13783). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11854 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/enumerations_controller.rb | 10 ++++------ app/views/enumerations/destroy.html.erb | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb index 125e87cff..2ca68f4f6 100644 --- a/app/controllers/enumerations_controller.rb +++ b/app/controllers/enumerations_controller.rb @@ -70,12 +70,10 @@ class EnumerationsController < ApplicationController @enumeration.destroy redirect_to enumerations_path return - elsif params[:reassign_to_id] - if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id]) - @enumeration.destroy(reassign_to) - redirect_to enumerations_path - return - end + elsif params[:reassign_to_id].present? && (reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id].to_i)) + @enumeration.destroy(reassign_to) + redirect_to enumerations_path + return end @enumerations = @enumeration.class.system.all - [@enumeration] end diff --git a/app/views/enumerations/destroy.html.erb b/app/views/enumerations/destroy.html.erb index 3b47b40b2..b469d4f9b 100644 --- a/app/views/enumerations/destroy.html.erb +++ b/app/views/enumerations/destroy.html.erb @@ -4,7 +4,7 @@

<%= l(:text_enumeration_destroy_question, @enumeration.objects_count) %>

-<%= select_tag 'reassign_to_id', (content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---") + options_from_collection_for_select(@enumerations, 'id', 'name')) %>

+<%= select_tag 'reassign_to_id', (content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---", :value => '') + options_from_collection_for_select(@enumerations, 'id', 'name')) %>

<%= submit_tag l(:button_apply) %> -- cgit v1.2.3