Yes it is possible.
You can do something like this:
def user_params
list_params_allowed = [:email, :title, :last_name, :first_name, :phone]
list_params_allowed << :role if current_user.admin?
params.require(:user).permit(list_params_allowed)
end
Thus, if you have new options, you need to add only one list (avoids errors).
If several parameters are added for the administrator, you can do this as follows:
list_params_allowed << :role << other_param << another_param if current_user.admin?
I hope for this help.
source
share