user.rb 1.58 KB
# -*- encoding : utf-8 -*-
# Author - Igor Portela - igorportela.com | Copyright(c) 2013. All rights reserved.
# == Schema Information
#
# Table name: users
#
#  id                     :integer(4)      not null, primary key
#  email                  :string(255)     default(""), not null
#  encrypted_password     :string(128)     default(""), not null
#  reset_password_token   :string(255)
#  reset_password_sent_at :datetime
#  remember_created_at    :datetime
#  sign_in_count          :integer(4)      default(0)
#  current_sign_in_at     :datetime
#  last_sign_in_at        :datetime
#  current_sign_in_ip     :string(255)
#  last_sign_in_ip        :string(255)
#  confirmation_token     :string(255)
#  confirmed_at           :datetime
#  confirmation_sent_at   :datetime
#  name                   :string(255)
#  state_id               :integer(4)
#  city_id                :integer(4)
#  address                :text
#  zipcode                :string(255)
#  phone                  :string(255)
#  created_at             :datetime        not null
#  updated_at             :datetime        not null
#
class User < ActiveRecord::Base
  # Relationships
  has_many :videos
  has_many :wikivideos
  belongs_to :city
  belongs_to :state

  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

  # Protection
  attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :city_id, :state_id, :zipcode, :phone, :address

  # Validates
  validates :email, :presence => true, :email => true

  # Scope
  default_scope order('created_at desc')
end