title: BCrypt::Errors::InvalidHash (invalid hash): even though credentials are in the database
body: <p>I'm trying to log in as this user on my web app</p>
  
  <pre><code>mysql&gt; SELECT*FROM users
      -&gt; ;
  +----+----------+-----------------+----------+
  | id | username | password_digest | initials |
  +----+----------+-----------------+----------+
  |  1 | Brett    | brett           | BK       |
  +----+----------+-----------------+----------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>but once I do it throws me this error:</p>
  
  <pre><code>BCrypt::Errors::InvalidHash (invalid hash):
  </code></pre>
  
  <p>Clearly I have a username and a password so I'm unsure why I'm not able to log in. I suspect it has something to do with the BCrypt gem and how it accepts passwords but I don't have a clue. Any ideas?</p>
  
  <p><strong>UPDATE:</strong> I found a different database on the server and my credentials look like this</p>
  
  <pre><code>mysql&gt; SELECT*FROM users;
  +----+----------+--------------------------------------------------------------+----------+
  | id | username | password_digest                                              | initials |
  +----+----------+--------------------------------------------------------------+----------+
  | 19 | Brett    | $2a$10$isws6DQxsJHzxCOI11miDesJPCNcQN2vfSzmsVpivBx020UshmqHG | BK       |
  +----+----------+--------------------------------------------------------------+----------+
  </code></pre>
  
  <p>How do I set my password to <code>brett</code> and use this crazy combination of numbers and letter to appear in the database? I wish to just use the command line interface.</p>
  
  <p>Here's my User class:</p>
  
  <pre><code>class User &lt; ApplicationRecord 
    attr_protected :id 
  
    has_secure_password 
    has_many :chats, dependent: :destroy 
    has_many :cnotes 
    has_one :permission, dependent: :destroy 
  
    validates :password, confirmation: true 
    validates :username, uniqueness: true 
  
    def to_param username end 
  
    def check_permission(permission) 
      self.permission[permission] 
    end 
  end
  </code></pre>