Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. Friends and Relationships > Listing friends

Listing friends

So far thanks to this chapter we already have lists of users and the functionality for our users to build relationships. Now we need to combine these to build a friends list for our users. This would either be a user viewing their own friends, or viewing the friends of another user.

Our friends

To view our own friends, we would visit http://oursite/relationships. This would call our relationship controller's default method, which needs to get our friends and display them on the page.

In our model, we need a query that looks up all relationships where we are either usera or userb, and depending on which we are, looks up the details of our connection from the other user field. This is done with a simple IF statement within the query.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint