[PATCH/foreman 1/1] Fixes #1388 - Not all errors reach the GUI

Signed-off-by: Paul Kelly <paul.ian.kelly@googlemail.com>

··· --- app/controllers/application_controller.rb | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 29d1570…6c72480 100644
— a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -206,10 +206,10 @@ class ApplicationController < ActionController::Base
else
hash[:redirect] ||= eval("#{controller_name}_url")
end

  • hash[:error_msg] ||= hash[:object].errors[:base]
  • hash[:error_msg] ||= hash[:object].errors.full_messages.flatten.uniq

    hash[:json_code] ||= :unprocessable_entity

  • logger.info “Failed to save: #{hash[:object].errors.full_messages.join(”, “)}”
  • logger.info “Failed to save: #{hash[:object].errors.full_messages.flatten.uniq.join(”, ")}"
    respond_to do |format|
    format.html do
    if hash[:render]

    1.7.5.4

This was done on purpose, as the errors are now shown inline (e.g.
next to the form element).
in which scenario did you not get all of the relevant errors?

Thanks,
Ohad

··· On Sat, Dec 10, 2011 at 10:59 AM, Paul Kelly wrote: > > Signed-off-by: Paul Kelly > --- > app/controllers/application_controller.rb | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb > index 29d1570..6c72480 100644 > --- a/app/controllers/application_controller.rb > +++ b/app/controllers/application_controller.rb > @@ -206,10 +206,10 @@ class ApplicationController < ActionController::Base > else > hash[:redirect] ||= eval("#{controller_name}_url") > end > - hash[:error_msg] ||= hash[:object].errors[:base] > + hash[:error_msg] ||= hash[:object].errors.full_messages.flatten.uniq > > hash[:json_code] ||= :unprocessable_entity > - logger.info "Failed to save: #{hash[:object].errors.full_messages.join(", ")}" > + logger.info "Failed to save: #{hash[:object].errors.full_messages.flatten.uniq.join(", ")}" > respond_to do |format| > format.html do > if hash[:render] > -- > 1.7.5.4 >

The errors that do not get displayed are errors[:conflict] messages. I
guess that as they are not associated with an element then they get ignored.

··· On 10 December 2011 11:41, Ohad Levy wrote:

On Sat, Dec 10, 2011 at 10:59 AM, Paul Kelly > paul.ian.kelly@googlemail.com wrote:

Signed-off-by: Paul Kelly paul.ian.kelly@googlemail.com

app/controllers/application_controller.rb | 4 +±-
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/controllers/application_controller.rb
b/app/controllers/application_controller.rb
index 29d1570…6c72480 100644
— a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -206,10 +206,10 @@ class ApplicationController <
ActionController::Base
else
hash[:redirect] ||= eval("#{controller_name}_url")
end

  • hash[:error_msg] ||= hash[:object].errors[:base]
  • hash[:error_msg] ||= hash[:object].errors.full_messages.flatten.uniq
hash[:json_code] ||= :unprocessable_entity
  • logger.info “Failed to save:
    #{hash[:object].errors.full_messages.join(”, “)}”
  • logger.info “Failed to save:
    #{hash[:object].errors.full_messages.flatten.uniq.join(”, ")}"
    respond_to do |format|
    format.html do
    if hash[:render]

    1.7.5.4

This was done on purpose, as the errors are now shown inline (e.g.
next to the form element).
in which scenario did you not get all of the relevant errors?

Thanks,
Ohad