From 8ed6d80b0d254fbbaf0f64d08041c97c8da671d0 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 23 Mar 2013 16:27:33 +0000 Subject: [PATCH] Reimplement User#is_friends_with? in a non-insane way --- app/models/user.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ef0dcc4b0..2e312119f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -142,14 +142,7 @@ class User < ActiveRecord::Base end def is_friends_with?(new_friend) - res = false - @new_friend = new_friend - self.friends.each do |friend| - if friend.friend_user_id == @new_friend.id - return true - end - end - return false + self.friends.where(:friend_user_id => new_friend.id).exists? end ## -- 2.39.5