summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/user.rb9
-rw-r--r--app/serializers/group_child_entity.rb2
2 files changed, 1 insertions, 10 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 8ce0fecc34d..4e71a3e11c2 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1073,15 +1073,6 @@ class User < ActiveRecord::Base
super
end
- # Get the membership for an object without loading the source of the membership
- #
- # This loads the entire `members` relation of the user, used on `current_user`
- def membership_for_object(object)
- members.sort('access_level_asc').detect do |member|
- object.is_a?(member.source_type.constantize) && member.source_id == object.id
- end
- end
-
protected
# override, from Devise::Validatable
diff --git a/app/serializers/group_child_entity.rb b/app/serializers/group_child_entity.rb
index 2f24ca9c4db..5c1fa72b1ac 100644
--- a/app/serializers/group_child_entity.rb
+++ b/app/serializers/group_child_entity.rb
@@ -72,7 +72,7 @@ class GroupChildEntity < Grape::Entity
def membership
return unless request.current_user
- @membership ||= request.current_user.membership_for_object(object)
+ @membership ||= request.current_user.members.find_by(source: object)
end
def project?