title: hashed password being stored as NULL :Ruby on rails
body: <p>I am trying to store a password after hashing it but it shows up as NULL in the database.I generated a  scaffold for users using password string and name string, and then altered the mysql table to store hashed password instead using this :</p>
  
  <pre><code>ALTER TABLE users CHANGE password hashed_password CHAR(40) NULL;
  </code></pre>
  
  <p>my model:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    attr_accessor :password
    attr_accessible :name, :password
  
    validates :name, :uniqueness =&gt; true
    validates :password, :length =&gt; { :in =&gt; 6..20 }
  
    def before_create
      self.hashed_password = User.hash_password(self.password)
    end
  
    def after_create
      @password = nil
    end
  
    private
  
    def self.hash_password(password)
      Digest::SHA1.hexdigest(password)
    end
  
  end
  </code></pre>
  
  <p>I am using Rails 3.2.13.</p>