From cacb978ebfc742b16ed1889ac93abd714a9a3fc4 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 25 Apr 2008 15:00:52 +0000 Subject: [PATCH] ActionItem315: fixed and improved error reporting for edit infos --- app/controllers/my_profile/profile_editor_controller.rb | 5 +++-- app/models/person.rb | 4 ++++ app/models/user.rb | 4 ++++ app/views/profile_editor/organization_info.rhtml | 3 +++ app/views/profile_editor/person_info.rhtml | 2 ++ app/views/shared/user_menu.rhtml | 4 ++-- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 262f7ea..2fa55c0 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -11,8 +11,9 @@ class ProfileEditorController < MyProfileController # edits the profile info (posts back) def edit if request.post? - profile.info.update_attributes(params[:info]) - redirect_to :action => 'index' + if profile.info.update_attributes(params[:info]) + redirect_to :action => 'index' + end else @info = profile.info render :action => @info.class.name.underscore diff --git a/app/models/person.rb b/app/models/person.rb index 5b9eaa1..eb87b84 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -103,4 +103,8 @@ class Person < Profile before_create :set_default_environment hacked_after_create :insert_default_homepage_and_feed + def name + person_info.name || self[:name] + end + end diff --git a/app/models/user.rb b/app/models/user.rb index e6ae5c0..d6f1c48 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -106,6 +106,10 @@ class User < ActiveRecord::Base save! unless new_record? end + def name + person.name + end + protected # before filter def encrypt_password diff --git a/app/views/profile_editor/organization_info.rhtml b/app/views/profile_editor/organization_info.rhtml index 1b019dc..b51ef8d 100644 --- a/app/views/profile_editor/organization_info.rhtml +++ b/app/views/profile_editor/organization_info.rhtml @@ -1,3 +1,6 @@ +

<%= _('Edit organization info') %>

+ +<%= error_messages_for :info %> <% labelled_form_for :info, @info do |f| %> <%= f.text_field(:contact_person) %> <%= f.text_field(:acronym) %> diff --git a/app/views/profile_editor/person_info.rhtml b/app/views/profile_editor/person_info.rhtml index 162ed9d..e10cb4c 100644 --- a/app/views/profile_editor/person_info.rhtml +++ b/app/views/profile_editor/person_info.rhtml @@ -1,5 +1,7 @@

<%= _('Edit person info') %>

+<%= error_messages_for :info %> + <% labelled_form_for :info, @info do |f| %> <%= f.text_field(:name) %> diff --git a/app/views/shared/user_menu.rhtml b/app/views/shared/user_menu.rhtml index 5c8b483..69d85dd 100644 --- a/app/views/shared/user_menu.rhtml +++ b/app/views/shared/user_menu.rhtml @@ -8,8 +8,8 @@ " alt="<%= current_user.login %> Icon-Photo" title="" height="20" border="0"/> - <%= _("%s's Menu") % current_user.login %> + %>" alt="<%= current_user.name %> Icon-Photo" title="" height="20" border="0"/> + <%= _("%s's Menu") % current_user.name %>
-- libgit2 0.21.2