Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5997651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:17:39+00:00 2026-05-23T00:17:39+00:00

On Chapter 7 from Michael Hartl’s tutorial there is a User model < code

  • 0

On Chapter 7 from Michael Hartl’s tutorial there is a User model <code here> that has a password attribute defined as a attr_accessor and also as attr_accessible with a presence validator.

The problem is: if I retrieve an existent User and try to update its email, ruby throws an exception claiming for its password, and I’m forced to re-set the password every time I want to update any other attribute. Example:

User.first.update_attributes!(:email => "example@mail.com")
ActiveRecord::RecordInvalid: Validation failed: Password can't be blank, Password is too short (minimum is 6 characters)

I added “:on => :create” next to the password’s presence validator and it seemed to solve the problem. Is this the right solution regarding a login system?

Anyone who has completed the Michael Harlt’s tutorial knows if that was an error or it was his real intention?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:17:40+00:00Added an answer on May 23, 2026 at 12:17 am

    You want to add the validator to the password hash field so that it is the actual password stored in the database which is checked. If you make the password= function set the value of a hash column, then this method will work independently of the actual password virtual variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to a chapter from beautiful code . And in that chapter
I just finished reading the Functions chapter from Uncle Bob's Clean Code . The
This is some sample code copied from The C++ Programming Language chapter 17 as
I am following this tutorial book that involves signing up and user creation for
I get this code example from Expert F# by Don Syme from chapter 13
I was reading the example chapter from the book by Ayende and on the
Can anyone explain to me the purpose of ungetch? This is from K&R chapter
I am currently running the following code based on Chapter 12.5 of the Python
Another chapter from the arguments between myself and the other senior developer series :P
I'm trying to go through the NerdDinner example chapter from the ASP.Net MVC 1.0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.