On 08/16/2011 11:51 AM, Jiri Tomasek wrote:
---
src/app/views/realms/_form.haml | 4 +---
src/app/views/roles/_form.haml | 2 +-
src/app/views/settings/self_service.haml | 1 -
src/app/views/users/_form.haml | 5 +----
4 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/src/app/views/realms/_form.haml b/src/app/views/realms/_form.haml
index d3812fa..42d879d 100644
--- a/src/app/views/realms/_form.haml
+++ b/src/app/views/realms/_form.haml
@@ -1,6 +1,4 @@
-- if @realm.errors.any?
- - @realm.errors.full_messages.each do |err|
- = err
+- error_messages_for @realm
%fieldset
= form.label :name, 'Realm Name'
= form.text_field :name, :title => 'realm_name', :value =>
@realm.name, :class => 'em long'
diff --git a/src/app/views/roles/_form.haml b/src/app/views/roles/_form.haml
index a22b97c..a3192a7 100644
--- a/src/app/views/roles/_form.haml
+++ b/src/app/views/roles/_form.haml
@@ -1,4 +1,4 @@
-= form.error_messages
+- error_messages_for @role
%fieldset
= form.label :name, 'Name'
= form.text_field :name, :class => "em long"
diff --git a/src/app/views/settings/self_service.haml
b/src/app/views/settings/self_service.haml
index c75471e..0e6e8c0 100644
--- a/src/app/views/settings/self_service.haml
+++ b/src/app/views/settings/self_service.haml
@@ -53,7 +53,6 @@
= t('.quota') + ":"
= text_field :self_service_default_quota, :maximum_running_instances, :class
=> 'grid_5'
.grid_2.la (instances)
- = form.error_message_on :maximum_running_instances, 'Maximum Running
Instances '
When we remove this, user is not notified about quota validation error,
you could replace above line with this:
= error_messages_for @self_service_default_quota if
@self_service_default_quota
-#%h3 POOLS
-#%fieldset.clearfix
%label.grid_2.alpha Permissions:
diff --git a/src/app/views/users/_form.haml b/src/app/views/users/_form.haml
index b353cd4..5e56d73 100644
--- a/src/app/views/users/_form.haml
+++ b/src/app/views/users/_form.haml
@@ -1,6 +1,4 @@
-%ul
- =(a)user.errors.full_messages.each do |msg|
- %li =msg
+- error_messages_for @user
%fieldset
%p
@@ -42,7 +40,6 @@
= quota_form.label :maximum_running_instances, t(:maximum_running_instances)
= quota_form.text_field :maximum_running_instances
(instances)
- = quota_form.error_message_on :maximum_running_instances, 'Maximum Running
Instances '
above error_messages is never displayed, because quota errors don't
propagate from RegistrationService to a user. I think it's a bug and
user shouldn't be created/saved if quota is invalid so I propose this:
we could replace above line with:
= error_messages_for @user.quota if @user and @user.quota
Then in separate patch fix registration service.
-if check_privilege(Privilege::MODIFY, User)
%fieldset
I hit error in error_messages_for helper (not related to this patch, but
it would be great to fix it), for some reason there can be this in
errors object:
{:maximum_running_instances=>[]}
Then obj.errors.present? returns false and I get nil error on line
flash[:error] << "#{attr.to_s.humanize} #{error}"
This fix worked for me:
def error_messages_for(obj)
- flash[:error] ||= "" if obj.errors.present?
+ return unless obj and obj.errors.present?
+ flash[:error] ||= ""
obj.errors.each_pair do |attr, error|
#TODO - Need to format this in some sensible way... <ul>?
flash[:error] << "#{attr.to_s.humanize} #{error}"
Jan