Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display error message correctly that is returned from model. #1115

Merged
merged 2 commits into from Apr 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions app/controllers/catalog_controller.rb
Expand Up @@ -268,9 +268,10 @@ def st_delete
if params[:id]
elements.push(params[:id])
process_sts(elements, 'destroy') unless elements.empty?
add_flash(_("The selected %{record} was deleted") %
{:record => ui_lookup(:table => "service_template")}) if @flash_array.nil?
self.x_node = "root"
if @flash_array.nil?
add_flash(_("The selected Catalog Item was deleted"))
self.x_node = "root"
end
else # showing 1 element, delete it
elements = find_checked_ids_with_rbac(ServiceTemplate)
if elements.empty?
Expand Down Expand Up @@ -632,7 +633,13 @@ def process_sts(sts, task, _display_name = nil)
add_flash(_("%{model} \"%{name}\": Error during '%{task}': %{error_message}") %
{:model => model_name, :name => st_name, :task => task, :error_message => bang.message}, :error)
else
AuditEvent.success(audit)
if st.errors
st.errors.each do |field, msg|
add_flash("#{field.to_s.capitalize} #{msg}", :error)
end
else
AuditEvent.success(audit)
end
end
end
end
Expand Down