changeset 61:aedfe093ec32 luisf

Now correctly creates a new user with the description
author luisf
date Thu, 02 Dec 2010 19:27:04 +0000
parents cf39b52d24b4
children 39db1b84d09f
files app/controllers/users_controller.rb app/models/ssamr_user_detail.rb
diffstat 2 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/users_controller.rb	Wed Dec 01 18:04:19 2010 +0000
+++ b/app/controllers/users_controller.rb	Thu Dec 02 19:27:04 2010 +0000
@@ -72,7 +72,7 @@
     render_404
   end
 
-  def new    
+  def new      
     @notification_options = User::MAIL_NOTIFICATION_OPTIONS
     @notification_option = Setting.default_notification_option
 
@@ -80,7 +80,7 @@
     @auth_sources = AuthSource.find(:all)
 
     @ssamr_user_details = SsamrUserDetail.new
-
+    
   end
   
   verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
@@ -98,12 +98,14 @@
     @user.pref.attributes = params[:pref]
     @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
 
-    @ssamr_user_details = @user.ssamr_user_detail
-    @ssamr_user_details.description = params[:ssamr_user_details][:description]
-    
+    @ssamr_user_details = SsamrUserDetail.new(params[:ssamr_user_details])
+
+    # associates the 2 objects
+    @user.ssamr_user_detail = @ssamr_user_details
+
     if @user.save
       @user.pref.save
-      
+                 
       @ssamr_user_details.save!
           
       @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
@@ -158,12 +160,11 @@
     
     @ssamr_user_details.save!
     
-
     if @user.save
       @user.pref.save
       @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
 
-      if was_activatedd
+      if was_activated
         Mailer.deliver_account_activated(@user)
       elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil?
         Mailer.deliver_account_information(@user, params[:password])
--- a/app/models/ssamr_user_detail.rb	Wed Dec 01 18:04:19 2010 +0000
+++ b/app/models/ssamr_user_detail.rb	Thu Dec 02 19:27:04 2010 +0000
@@ -1,5 +1,3 @@
 class SsamrUserDetail < ActiveRecord::Base
   belongs_to :user
-
-  validates_presence_of :user
 end