Add a scope to preload emails on a user
This commit is contained in:
parent
7fa7f03e77
commit
08e3907b7f
1 changed files with 1 additions and 0 deletions
|
@ -275,6 +275,7 @@ class User < ApplicationRecord
|
||||||
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
||||||
scope :by_username, -> (usernames) { iwhere(username: Array(usernames).map(&:to_s)) }
|
scope :by_username, -> (usernames) { iwhere(username: Array(usernames).map(&:to_s)) }
|
||||||
scope :for_todos, -> (todos) { where(id: todos.select(:user_id)) }
|
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.
|
# Limits the users to those that have TODOs, optionally in the given state.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue