user.rb
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- 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