From 97c5362cfecee611e8bcae4c9ea0353da20b2cea Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 2 Dec 2009 21:18:05 +0000 Subject: [PATCH] Fixed: no error message when creating a category from the issue form fails (#1477). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3118 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1e80a713..75affee3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -197,17 +197,26 @@ class ProjectsController < ApplicationController # Add a new issue category to @project def add_issue_category @category = @project.issue_categories.build(params[:category]) - if request.post? and @category.save - respond_to do |format| - format.html do - flash[:notice] = l(:notice_successful_create) - redirect_to :action => 'settings', :tab => 'categories', :id => @project + if request.post? + if @category.save + respond_to do |format| + format.html do + flash[:notice] = l(:notice_successful_create) + redirect_to :action => 'settings', :tab => 'categories', :id => @project + end + format.js do + # IE doesn't support the replace_html rjs method for select box options + render(:update) {|page| page.replace "issue_category_id", + content_tag('select', '' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') + } + end end - format.js do - # IE doesn't support the replace_html rjs method for select box options - render(:update) {|page| page.replace "issue_category_id", - content_tag('select', '' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') - } + else + respond_to do |format| + format.html + format.js do + render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) } + end end end end