class User

Model for a user

Overview

A user has a name, password and authentication token

Schema Information

Table name: users

id                     :integer          not null, primary key
username               :string           default(""), not null
encrypted_password     :string           default(""), not null
reset_password_token   :string
reset_password_sent_at :datetime
remember_created_at    :datetime
sign_in_count          :integer          default(0), not null
current_sign_in_at     :datetime
last_sign_in_at        :datetime
current_sign_in_ip     :string
last_sign_in_ip        :string
created_at             :datetime
updated_at             :datetime
auth_token             :string           default("")

Public Instance Methods

generate_authentication_token!() click to toggle source

Set auth_token attribute to a new value

# File app/models/user.rb, line 36
def generate_authentication_token!
  begin
    self.auth_token = Devise.friendly_token
  end while self.class.exists?(auth_token: auth_token)
end