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
This commit is contained in:
Ramesh Naidu Allu 2021-03-24 15:12:58 +05:30 committed by GitHub
parent aca08cfb11
commit 0911cd4a5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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