aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Houston <robin@lenny.robin>2011-06-23 06:18:37 +0100
committerRobin Houston <robin@lenny.robin>2011-06-23 06:18:37 +0100
commitf388281ea84653eb403fe481f0a8812b4ed10061 (patch)
tree13ebfa0942910842b5a8642575935e9205f80fcb
parent4ac1e9a0a0e56a53ca1e735069b554d73424984b (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.
-rw-r--r--app/helpers/application_helper.rb27
-rw-r--r--app/models/public_body.rb4
-rw-r--r--app/views/request/_followup.rhtml4
3 files changed, 21 insertions, 14 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
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index d5538fb6e..520e28aab 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -33,8 +33,8 @@ require 'set'
class PublicBody < ActiveRecord::Base
strip_attributes!
- validates_presence_of :name, :message => N_("can't be blank")
- validates_presence_of :url_name, :message => N_("can't be blank")
+ validates_presence_of :name, :message => N_("Name can't be blank")
+ validates_presence_of :url_name, :message => N_("URL name can't be blank")
validates_uniqueness_of :short_name, :message => N_("Short name is already taken"), :if => Proc.new { |pb| pb.short_name != "" }
validates_uniqueness_of :name, :message => N_("Name is already taken")
diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.rhtml
index de9d5530d..c2be323a2 100644
--- a/app/views/request/_followup.rhtml
+++ b/app/views/request/_followup.rhtml
@@ -63,9 +63,9 @@
<h3>What are you doing?</h3>
<% if !@outgoing_message.errors[:what_doing_dummy].nil? %>
- <div class="fieldWithErrors">
+ <div class="fieldWithErrors">
<% else %>
- <div>
+ <div>
<% end %>
<!--
<div>