From 173f2511484d70cc03e01fe78b8c3c29c9844a4a Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sat, 15 Aug 2015 01:57:17 +0300 Subject: [PATCH] Implement personal profile building for User --- app/models/user.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1124038..002d401 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,9 +9,11 @@ class User < ActiveRecord::Base has_many :workshops has_many :events - # TODO (2015-08-05) Copy previous profile - def build_personal_profile(conference, params) - personal_profiles.build({conference_id: conference.id}.merge(params)) + def build_personal_profile(conference, params = {}) + new_personal_profile = personal_profiles.last.dup || personal_profiles.build + new_personal_profile.conference = conference + new_personal_profile.assign_attributes params + new_personal_profile end def personal_profile(conference)