# Seach users to invite, how ineficient is what I use?

**URL:** <https://www.ruby-forum.com/t/seach-users-to-invite-how-ineficient-is-what-i-use/151097>\
**Category:** Rails\
**Created:** [October 16, 2008, 7:24pm UTC](https://www.ruby-forum.com/t/seach-users-to-invite-how-ineficient-is-what-i-use/151097 "2008-10-16T19:24:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 16, 2008, 7:24pm UTC](https://www.ruby-forum.com/t/seach-users-to-invite-how-ineficient-is-what-i-use/151097/1 "2008-10-16T19:24:57Z")

</div>

Hi,

I’m using HasManyFriends plugin.

I’m listing friends so users can request friendship. From those I have  
to remove the admin, the current user and users that are friends  
already.

For that I used this:

def index  
@users = User.find(:all)

```
render :inline =>
"<% for user in @users %>
  <% if !user.has_role?('administrator') && user != current_user &&

```

(!user.is\_friends\_with? current\_user) %\>  
\<%=h user.login %\>  
&nbsp; &nbsp; &nbsp;  
\<%= link\_to ‘Invite this user’, :action =\> ‘process\_invitation’,  
:invite =\> user ,:command =\> ‘invite’ unless  
(user.has\_role?(‘administrator’) || user == current\_user) %\>  
  
  
\<% end %\>  
\<% end %\>"  
end

I think that’s not the most optimal way.  
Any hints how to do it better?

Note, I’m planning to include a city filter for the first user fecth  
soon.

Thanks

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 17, 2008, 12:38pm UTC](https://www.ruby-forum.com/t/seach-users-to-invite-how-ineficient-is-what-i-use/151097/2 "2008-10-17T12:38:44Z")

</div>

Any comments anyone?  
I guess my code is perfect otherwise 🕶

Maybe I didn’t formulate the right question…

Regards
