-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PC-30: Users management in ActiveAdmin #35
base: master
Are you sure you want to change the base?
Conversation
ActiveAdmin.register User do | ||
permit_params do | ||
params = [:name, :email] | ||
params += [:password, :password_confirmation] if request.params.dig(:user, :password).present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check request.params.dig(:user, :password).present?
in permit_params is unnecessary since ActiveAdmin does not send empty fields — it can be removed. Make sure that password updates work correctly when updating a user.
permit_params :name, :email, :password, :password_confirmation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use permit_params :name, :email, :password, :password_confirmation
, then entering a password becomes mandatory, when updating a user, which does not meet the requirements "The password field is optional and will only be updated if filled." (PC-33).
Therefore, the following approach is applied: params += [:password, :password_confirmation] if request.params.dig(:user, :password).present?
This ensures that the :password and :password_confirmation parameters are added only if the password field is not empty.
Hello Team, please review this PR.