Forum: Ruby on Rails Seach users to invite, how ineficient is what I use?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2927af2b9ddd2f3f34b316755b8f4dfb?d=identicon&s=25 comopasta Gr (dgj)
on 2008-10-16 19:24
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) %>
        <br>
      <% 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
2927af2b9ddd2f3f34b316755b8f4dfb?d=identicon&s=25 comopasta Gr (dgj)
on 2008-10-17 12:38
Any comments anyone?
I guess my code is perfect otherwise 8-)

Maybe I didn't formulate the right question...

Regards
This topic is locked and can not be replied to.