I'm new to rails and devise, so I'm trying to understand what is going on. I am following the devise wiki for allowing users to edit their own password, found here: https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-password.
What I find confusing is that even though I am using :validatable in my model, it seems that I am able to submit the form even if I leave password/password_confirmation blank, as long as I complete current_password. It seems this has something to do with the fact that in validatable.rb, that there is a validation for password only if !password.nil? per line 54.
So I decided to look at debug(params) on form submission, and it seems indeed that if I leave the password/password_confirmation fields blank, then password/password_confirmation do not appear in the params hash at all (and though password.nil? is true?).
What I don't understand is why this happens? Even if I leave the password field blank, shouldn't password appear in params just like any other field, as "password" => ""? Since I'm using my own controller action to process the form, how is it that password is not in params?
flash[:notice] = params[:user]
When I leave the password/password_confirmation fields blank on the form, the flash notice simply states "{}". However, I do see in the server console that "password" => "[FILTERED]". – robotron2000params[:user][:password].nil?
on submission of a blank password field. You are right, the field is NOT nil, only blank. Guess now I'm confused as to whyflash[:notice] = params[:user]
returns {} only? Since password is blank, I would've thought that the devise's validatable shown here would've caught the validation error on blank password submission. – robotron2000