title: Undefined Method attr_accessible
body: <p>I am somewhat new to rails and I am trying to create a User login.  I went through the tutorial found <a href="http://www.sitepoint.com/rails-userpassword-authentication-from-scratch-part-i/" rel="noreferrer">here</a>.  At the end it had me add "attr_accessible" for mass assignment.  However when I did that I got the following error:</p>
  
  <pre><code>undefined method `attr_accessible' for #&lt;Class:0x007ff70f276010&gt;
  </code></pre>
  
  <p>I saw on this <a href="https://stackoverflow.com/questions/10273812/ruby-on-rails-undefined-method-attr-accessible-and-before-save">post</a> that I neeed &lt; ActiveRecord::Base.  But I do have that included.  Here is the code for my User Model:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  
    attr_accessor :password
    EMAIL_REGEX = /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\z/i
    validates :username, :presence =&gt; true, :uniqueness =&gt; true, :length =&gt; { :in =&gt; 3..20 }
    validates :email, :presence =&gt; true, :uniqueness =&gt; true, :format =&gt; EMAIL_REGEX
    validates :password, :confirmation =&gt; true #password_confirmation attr
    validates_length_of :password, :in =&gt; 6..20, :on =&gt; :create
    before_save :encrypt_password
    after_save :clear_password
    attr_accessible :username, :email, :password, :password_confirmation
  
    def encrypt_password
      if password.present?
        self.salt = BCrypt::Engine.generate_salt
        self.encrypted_password= BCrypt::Engine.hash_secret(password, salt)
      end
    end
  
    def clear_password
      self.password = nil
    end
  
  end
  </code></pre>
  
  <p>Any other ideas on what could be causing this problem would be really appreciated, thanks!</p>
  
  <p>Edit:  On Rails 4.1.  Looks like it doesn't apply anymore.  Thanks fotanus</p>