Rails Recipes 18 - Self-referential relationships?

For starters, you need to pass both user ids to your controller, something like:

<%= link_to 'Add as a friend', :controller => 'users', :action
=>'friendify', :id=>@current_user, :friend_id=>some_other_user.id %>

You should then be able to add the friend to the collection directly:

def friendify
  @user = User.find(params[:id])
  @new_friend = User.find(params[:friend_id])
  @user.friends << @new_friend
end

Cheers,
Max