A post-request is executed in the users_controller controller to change the data in the object with the user model, parameters are passed to the post from edit.html.erb. How to remove from params parameter :password and :password_confirmation , if the fields on the form are empty?

  <div class="field"> <%= f.label :password %> <br/> <%= f.password_field :password %> </div> <div class="field"> <%= f.label :password_confirmation %> <br/> <%= f.password_field :password_confirmation %> </div> 

    1 answer 1

    And in dock on Hash to look in any way?

     params.delete[:password] unless params[:password].present? params.delete[:password_confirmation] unless params[:password_confirmation].present? 
    • In general, params not Hash . But it works as they wrote. - Vladimir Gordeev
    • So I’m trying to do it anyway , I don’t want it either, makes the password empty ... - Niki-Timofe