From 0911cd4a5c172d1f72d6690599855bc1c894a485 Mon Sep 17 00:00:00 2001 From: Ramesh Naidu Allu Date: Wed, 24 Mar 2021 15:12:58 +0530 Subject: [PATCH] Save valid attributes with ignoring the invalid ones (#12633) * add save_valid_attributes method in profile * undo save_valid_attributes method * Render the settings page with user entered params incase of failed update --- app/controllers/profiles_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 19048bfb9..ef02e2c8d 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -6,10 +6,16 @@ class ProfilesController < ApplicationController update_result = Profiles::Update.call(current_user, update_params) if update_result.success? flash[:settings_notice] = "Your profile has been updated" + redirect_to user_settings_path else + @user = current_user + @tab = "profile" flash[:error] = "Error: #{update_result.errors_as_sentence}" + render template: "users/edit", locals: { + user: update_params[:user], + profile: update_params[:profile] + } end - redirect_to user_settings_path end private