# Code to allow only friends

**URL:** <https://www.ruby-forum.com/t/code-to-allow-only-friends/152940>\
**Category:** Rails\
**Created:** [November 10, 2008, 8:08am UTC](https://www.ruby-forum.com/t/code-to-allow-only-friends/152940 "2008-11-10T08:08:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [November 10, 2008, 8:08am UTC](https://www.ruby-forum.com/t/code-to-allow-only-friends/152940/1 "2008-11-10T08:08:57Z")

</div>

I have an app in which, I have profiles which has friends list… I want  
to apply some privacy settings as to allow, to visit only their friends  
in network…How to write the code in controller… can anybody pls  
explain me… I am new to ror.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [November 11, 2008, 5:24pm UTC](https://www.ruby-forum.com/t/code-to-allow-only-friends/152940/2 "2008-11-11T17:24:42Z")

</div>

Santosh T. wrote:

> I have an app in which, I have profiles which has friends list… I want  
> to apply some privacy settings as to allow, to visit only their friends  
> in network…How to write the code in controller… can anybody pls  
> explain me… I am new to ror.

That’s just implementating constraints via relationships. Assuming that  
you’ve created some type of “User” and “FriendsList” models, they  
obviously have some sort of relationship. So in your controller actions,  
simply access the friends list via the relationship.

If you don’t know how to do that, I strongly recommend that you buy and  
read the newest (beta) edition of Agile Web D. With Rails:  
[http://pragprog.com/titles/rails3/](http://pragprog.com/titles/rails3/)

I hope that helps. Cheers,  
-Nick
