diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-02-08 18:28:21 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-02-08 18:28:21 +0100 |
commit | 08e3907b7fd0e8d602a39c0e3f3309e81fa05e82 (patch) | |
tree | 581cda50c43640a035d25ecdc35ba2964d68f078 | |
parent | 7fa7f03e77609e01e7c280ec627908ebc21fd8bc (diff) | |
download | gitlab-ce-08e3907b7fd0e8d602a39c0e3f3309e81fa05e82.tar.gz |
Add a scope to preload emails on a user
-rw-r--r-- | app/models/user.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 24101eda0b1..0d52006db28 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -275,6 +275,7 @@ class User < ApplicationRecord scope :confirmed, -> { where.not(confirmed_at: nil) } scope :by_username, -> (usernames) { iwhere(username: Array(usernames).map(&:to_s)) } scope :for_todos, -> (todos) { where(id: todos.select(:user_id)) } + scope :with_emails, -> { preload(:emails) } # Limits the users to those that have TODOs, optionally in the given state. # |