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
class User < ActiveRecord::Base

    has_many :emails
    has_many :websites
    has_many :addresses
    has_many :phones
    has_many :occupations
    has_many :contacts
    has_many :avatars
    has_many :tags
    has_many :messages
    has_many :checkins

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

    attr_accessible :firstname,
                    :lastname,
                    :nickname,
                    :bio,
                    :email,
                    :fb_uid,
                    :fb_token,
                    :password,
                    :password_confirmation,
                    :remember_me,
                    :latitude,
                    :longitude

    before_save :ensure_authentication_token

    def last_message

        self.messages.first

    end

end