password_non_blank p159
Dustin Tigner
15 posts
|
Greetings, Could someone explain to me the importance of having password_non_blank on page 159? When you do not enter a password and submit the form, the form shows an error for the password, though does not highlight the password field.
This is my second time reading over this section of the book. I’m trying to program a user system for my first official Rails application. Thanks for your help! ~Dustin Tigner |
Dustin Tigner
15 posts
|
What is the point of this forum if it is not to ask questions? I didn’t feel the book explained this method very well and would like more information. What’s wrong with just checking the presence of the password and password_confirmation content? If these two fields were filled in and matched, then it’s obvious that there would be a hashed password. Just check the database. Any information would be helpful. Thanks! ~Dustin Tigner |
Dave Thomas
Administrator
72 posts
|
Dustin: First a point about forum etiquette. Of course you can post questions. But you also seem to feel entitled to answers. This is not the case. People will do what they can to help, but you can’t demand it of them. Other readers chip in. So do authors, if they have the time. On to your question. Ask yourself what’s being validated? Is it user input, or is it the model. If the latter, then it should be the model field that’s tested. Consider the case of an edit screen that lets a user update their contact details but not their password. The data from the user would not contain the two password fields. If they were being validated, then the update would fail. Always validate the canonical data. Then validate the ethereal if appropriate. —Dave Thomas |
Dustin Tigner
15 posts
|
Thanks Dave, I apologize if I came off as harsh or demanding. I’m used to communities such as Larry Ullman’s PHP forums where the community is a bit more active and willing to answer questions. I understand that my questions are not your top priority and appreciate when I do receive answers. My main concern here is that this board invites question and suggestions. If members were to post questions and not receive answers, the reader, like myself, would feel a bit abandoned. I purchased the book and felt as if the boards here were an extended service – something that only those who are customers may use and receive additional help. With that in mind, I’m sorry if I did expect some sort of assistance. If I didn’t, I wouldn’t have posted. I waited three days for a reply before posting again. I feel that this shows that I was indeed patient and not as demanding as you may have stated. I posted my question here because it related directly with your product. Next time I’ll reframe from doing so. Your answer was very helpful and direct to the point. Thank you for your time and assistance. ~Dustin Tigner |
Sam Ruby
197 posts
|
Try: errors.add(:password, "missing") if hashed_password.blank? |
Dustin Tigner
15 posts
|
Thanks Sam, I’ve made the change in my depot application and works very well. With your new code snippet, and Dave’s explanation, I feel I understand the reasoning behind the extra bit of code. Thanks for taking the time to answer my question. Have a good day! ~Dustin Tigner |
Dave Thomas
Administrator
72 posts
|
Dustin: These forums primarily allow readers to help other readers. The reality is, with tens of thousands of book owners, providing support from the authors to every reader’s question just wouldn’t be practical. Feel free to post questions. But don’t feel cheated if no one answers for three days. It just doesn’t work that way. Dave |
7 posts, 3 voices
