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
    def index

        @contacts = current_user.contacts

        @users = Array.new

        @messages = Array.new

        @contacts.each do |contact|

            user = User.find(contact.friend_id)

            @users << user

        end

        @users.sort! { |a,b| a.firstname.downcase <=> b.firstname.downcase }

        respond_to do |format|

            format.html { render :text => 'Use either JSON or XML' }
            format.json { render :json => @users, :methods => [:last_message], :only => [:id, :firstname, :lastname, :nickname, :email, :bio]}
            format.xml { render :xml => @users, :methods => [:last_message], :only => [:id, :firstname, :lastname, :nickname, :email, :bio]}

        end

    end