]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Merge branch 'master' into notes
[rails.git] / app / models / user.rb
index ef0dcc4b0f150a9f5c99942b8a819938e07b24e7..778afbf8a9c7ae26d76339905209a447ae9e92eb 100644 (file)
@@ -12,6 +12,8 @@ class User < ActiveRecord::Base
   has_many :tokens, :class_name => "UserToken"
   has_many :preferences, :class_name => "UserPreference"
   has_many :changesets, :order => 'created_at DESC'
+  has_many :note_comments, :foreign_key => :author_id
+  has_many :notes, :through => :note_comments
 
   has_many :client_applications
   has_many :oauth_tokens, :class_name => "OauthToken", :order => "authorized_at desc", :include => [:client_application]
@@ -142,14 +144,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
 
   ##