From e762acebfbfdf7e44eab880b187f3601f9c9cb5d Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sun, 9 Oct 2016 04:20:45 +0300 Subject: [PATCH] Auto-fill personal profile from other conference --- .../management/personal_profiles_controller.rb | 12 ++++++------ config/locales/bg.yml | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/management/personal_profiles_controller.rb b/app/controllers/management/personal_profiles_controller.rb index 7997b7b..5bc4de6 100644 --- a/app/controllers/management/personal_profiles_controller.rb +++ b/app/controllers/management/personal_profiles_controller.rb @@ -26,18 +26,18 @@ module Management def new @conference = find_conference - @profile = @conference.participant_profiles. - build(user_id: params[:user_id]) + @user = User.find params[:user_id] + @profile = @user.build_personal_profile(@conference) end def create @conference = find_conference - @profile = PersonalProfile.new(profile_params) - @profile.conference = @conference + @user = User.find(profile_params[:user_id]) + @profile = @user.build_personal_profile(@conference, profile_params) if @profile.save - flash[:notice] = 'Profile was successfully created.' - redirect_to action: :index + flash[:notice] = t('.successfully_created') + redirect_to management_conference_personal_profile_path(@profile, conference_id: @conference.id) else render action: :new end diff --git a/config/locales/bg.yml b/config/locales/bg.yml index d93361a..848de07 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -4,6 +4,8 @@ bg: index: no_profile: 'Този потребител няма въведен профил за текущата конференция.' total: "%{current} от общо %{total}" + create: + successfully_created: "Профилът беше създаден успешно." conferences: show: summary: 'Обобщение'