diff options
author | Robin Houston <robin@lenny.robin> | 2011-06-23 06:18:37 +0100 |
---|---|---|
committer | Robin Houston <robin@lenny.robin> | 2011-06-23 06:18:37 +0100 |
commit | f388281ea84653eb403fe481f0a8812b4ed10061 (patch) | |
tree | 13ebfa0942910842b5a8642575935e9205f80fcb /app/helpers/application_helper.rb | |
parent | 4ac1e9a0a0e56a53ca1e735069b554d73424984b (diff) |
The error messages are clearly designed to be used *without* the
field name being prepended, so change the ApplicationHelper::foi_error_messages_for
method to not prepend the field name, and add the field name back to the
two messages from which we previously removed it.
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a9474ef0f..e46404a72 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -19,22 +19,29 @@ module ApplicationHelper objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact count = objects.inject(0) {|sum, object| sum + object.errors.count } unless count.zero? - html = {} - [:id, :class].each do |key| - if options.include?(key) - value = options[key] - html[key] = value unless value.blank? - else - html[key] = 'errorExplanation' - end + html = {} + [:id, :class].each do |key| + if options.include?(key) + value = options[key] + html[key] = value unless value.blank? + else + html[key] = 'errorExplanation' + end + end + + error_messages = [] + for object in objects + object.errors.each do |attr, message| + error_messages << content_tag(:li, message) + end end - error_messages = objects.map {|object| object.errors.full_messages.map {|msg| content_tag(:li, msg) } } + content_tag(:div, content_tag(:ul, error_messages), html ) else - '' + '' end end |