From 5bff0b1ddbd744b86cfe31e616878b4190a6fea6 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 12 Sep 2007 05:05:43 +0000 Subject: [PATCH] ActionItem7: making everything work together --- app/controllers/application.rb | 6 +++++- app/controllers/profile_editor_controller.rb | 5 ++++- app/helpers/application_helper.rb | 8 ++++++++ app/models/person.rb | 1 + app/models/person_info.rb | 2 +- app/views/profile_editor/index.rhtml | 5 +++++ app/views/profile_editor/person_info.rhtml | 13 +++++++++++++ db/migrate/013_create_person_infos.rb | 1 + test/fixtures/person_infos.yml | 7 +++++++ test/functional/profile_editor_controller_test.rb | 44 +++++++++++++++++++++++++++++++++++++++++--- test/integration/edit_enterprise_test.rb | 2 +- test/integration/editing_person_info_test.rb | 27 +++++++++++++++++++++++++++ test/unit/person_info_test.rb | 3 +-- 13 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 app/views/profile_editor/index.rhtml create mode 100644 app/views/profile_editor/person_info.rhtml create mode 100644 test/fixtures/person_infos.yml create mode 100644 test/integration/editing_person_info_test.rb diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 93c82b2..2b7fcd3 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -30,10 +30,14 @@ class ApplicationController < ActionController::Base before_filter :load_profile_from_params def load_profile_from_params if params[:profile] - @profile = Profile.find_by_identifier(params[:profile]) + @profile ||= Profile.find_by_identifier(params[:profile]) end end + def profile + @profile + end + def self.acts_as_virtual_community_admin_controller before_filter :load_admin_controller end diff --git a/app/controllers/profile_editor_controller.rb b/app/controllers/profile_editor_controller.rb index 3c4bfce..729a312 100644 --- a/app/controllers/profile_editor_controller.rb +++ b/app/controllers/profile_editor_controller.rb @@ -4,8 +4,11 @@ class ProfileEditorController < ApplicationController # edits the profile info (posts back) def edit if request.post? + profile.info.update_attributes(params[:info]) + redirect_to :action => 'index' else - render :action => profile.info.class.tableize + @info = profile.info + render :action => @info.class.name.underscore end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6dd96c2..6c21404 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -158,4 +158,12 @@ module ApplicationHelper @profile || raise("There is no current profile") end + # displays an + # + # Current implementation generates a