title: Trouble saving an updated password record from rails console
body: <p>I'm writing a simple application and am having some difficulties updating a user's password from within rails console. I'm VERY new to RoR (and Ruby). I'm sure there's something simple I'm missing. I've included my model as well as the output I get from Terminal.</p>
  
  <p><strong>admin_users.rb Model</strong></p>
  
  <pre><code>    require 'digest/sha1'
  class AdminUser &lt; ActiveRecord::Base
  
    attr_accessor :password
  
    EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]\.[A-Z]{2,4}$/i
  
    def self.authenticate(username="", password="")
      user = AdminUser.find_by_username(username)
      if user &amp;&amp; user.password_match?(password)
          return user
      else
          return false
      end
    end
  
    def password_match?(password="")
      hashed_password == AdminUser.hash_with_salt(password, salt)
    end
  
    validates :first_name, :presence =&gt; true, :length =&gt; { :maximum =&gt; 25 }
    validates :last_name, :presence =&gt; true, :length =&gt; { :maximum =&gt; 50 }
    validates :username, :presence =&gt; true, :length =&gt; { :within =&gt; 8..25 }, :uniqueness =&gt; true
    validates :email, :presence =&gt; true, :length =&gt; { :maximum =&gt; 100 }, :uniqueness =&gt; true, :format=&gt; EMAIL_REGEX, :confirmation =&gt; true
  
    # only on create ,so other attributes of this user can be changed
    validates_length_of :password, :within =&gt; 8..25, :on =&gt; :create
  
    before_save :create_hashed_password
    after_save :clear_password
  
    # scope :named, lambda {|first, last| where (:first_name =&gt; first, :last_name =&gt; last)}
  
    attr_protected :hashed_password, :salt
  
    def self.make_salt(username="")
      Digest::SHA1.hexdigest("Use #{username} with #{Time.now} to make salt")
    end
  
    def self.hash_with_salt(password="", salt="")
      Digest::SHA1.hexdigest("Put #{salt} on #{password}")
    end
  
    private
  
    def create_hashed_password
      # Whenever :password has a value, hashing is needed
      unless password.blank?
        #always use "self" when assigning values
        self.salt = AdminUser.make_salt(username) if salt.blank?
        self.hashed_password = AdminUser.hash_with_salt(password, salt)
      end
    end
  
    def clear_password
      # for security reasons and because hasing is not needed
      self.password = nil
    end
  
  end
  </code></pre>
  
  <p><strong>Terminal</strong> - </p>
  
  <pre><code>user = AdminUser.find(1)
  user.password = ('secretpassword')
  user.save
  </code></pre>
  
  <p>Then terminal gives me this...</p>
  
  <pre><code>    (0.1ms)  BEGIN
    AdminUser Exists (0.4ms)  SELECT 1 AS one FROM `admin_users` WHERE (`admin_users`.`username` = BINARY 'benlinus' AND `admin_users`.`id` != 1) LIMIT 1
    AdminUser Exists (0.2ms)  SELECT 1 AS one FROM `admin_users` WHERE (`admin_users`.`email` = BINARY 'email.email@me.com' AND `admin_users`.`id` != 1) LIMIT 1
     (0.1ms)  ROLLBACK
   =&gt; false 
  2.0.0-p195 :018 &gt; user.save
     (0.1ms)  BEGIN
    AdminUser Exists (0.3ms)  SELECT 1 AS one FROM `admin_users` WHERE (`admin_users`.`username` = BINARY 'benlinus' AND `admin_users`.`id` != 1) LIMIT 1
    AdminUser Exists (0.2ms)  SELECT 1 AS one FROM `admin_users` WHERE (`admin_users`.`email` = BINARY 'email.email@me.com' AND `admin_users`.`id` != 1) LIMIT 1
     (0.1ms)  
  </code></pre>
  
  <p>I'm not sure where the hangup is. It doesn't appear that I'm getting errors in my validation, so I'm left a little bit confused. </p>