title: ArgumentError in Chapter 7 of "Rails Tutorial" by Michael Hartl
body: <p>everyone. I've got the following problem:
  After implementing has_password? in section 7.2.3 RSpec displays the following error for "should create a new instance given valid attributes" test for example</p>
  
  <blockquote>
    <p>1) User should create a new instance given valid attributes
         Failure/Error: User.create!(@attr)
         ArgumentError:
           wrong number of arguments (1 for 0)
         # ./app/models/user.rb:42:in <code>secure_hash'
         # ./app/models/user.rb:39:in</code>make_salt'
         # ./app/models/user.rb:30:in <code>encrypt_password'
         # ./spec/models/user_spec.rb:14:in</code>block (2 levels) in '</p>
    
    <p>Finished in 1.47 seconds
    1 example, 1 failure
      &lt;-- Slave(1) run done!</p>
  </blockquote>
  
  <p>I don't understand, what exactly causes the problem.
  Here is my user.rb code:</p>
  
  <pre><code>    require 'digest'
  
  class User &lt; ActiveRecord::Base 
    attr_accessor :password
    attr_accessible :name, :email, :password, :password_confirmation
  
    email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  
    validates :name,  :presence =&gt; true,
                      :length   =&gt; { :maximum =&gt; 50 }
    validates :email, :presence =&gt; true,
                       :format   =&gt; { :with =&gt; email_regex },
                       :uniqueness =&gt; { :case_sensitive =&gt; false }
  
    # Automatically create the virtual attribute "password_confirmation"
    validates :password, :presence =&gt; true,
                      :confirmation =&gt; true,
                      :length =&gt; { :within =&gt; 6..40 } 
  
    before_save :encrypt_password
  
    # Return 'true' if the user's password matches the submitted password
    def has_password?(submitted_password)
      encrypted_password == encrypt(submitted_password)
    end
  
    private
  
    def encrypt_password
      self.salt = make_salt if new_record?
      self.encrypted_password = encrypt(password)
    end
  
    def encrypt(string)
      secure_hash("#{salt}--#{string}")
    end
  
    def make_salt
      secure_hash("#{Time.now.utc}--#{password}")
    end
  
    def secure_hash
      Digest::SHA2.hexdigest(string)
    end
  end
  </code></pre>
  
  <p>What can it be?
  Thank you in advance!</p>