summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 1bc070f040d..c2486fd3a16 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -77,7 +77,6 @@ class User < ActiveRecord::Base
delegate :path, to: :namespace, allow_nil: true, prefix: true
# Scopes
- scope :not_in_project, ->(project) { where("id not in (:ids)", ids: project.users.map(&:id) ) }
scope :admins, where(admin: true)
scope :blocked, where(blocked: true)
scope :active, where(blocked: false)
@@ -93,6 +92,14 @@ class User < ActiveRecord::Base
end
end
+ def not_in_project(project)
+ if project.users.present?
+ where("id not in (:ids)", ids: project.users.map(&:id) )
+ else
+ scoped
+ end
+ end
+
def without_projects
where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)')
end