Error when adding user to group where he is already assigned (#18665).

git-svn-id: http://svn.redmine.org/redmine/trunk@13785 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2014-12-21 20:15:24 +00:00
parent a3d4b63261
commit c0800b330c
3 changed files with 29 additions and 8 deletions

View File

@@ -637,12 +637,14 @@ class ApplicationController < ActionController::Base
end
# Renders API response on validation failure
# for an object or an array of objects
def render_validation_errors(objects)
if objects.is_a?(Array)
@error_messages = objects.map {|object| object.errors.full_messages}.flatten
else
@error_messages = objects.errors.full_messages
end
messages = Array.wrap(objects).map {|object| object.errors.full_messages}.flatten
render_api_errors(messages)
end
def render_api_errors(*messages)
@error_messages = messages.flatten
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => nil
end