Add a scope to preload emails on a user

This commit is contained in:
Bob Van Landuyt 2019-02-08 18:28:21 +01:00
parent 7fa7f03e77
commit 08e3907b7f

View file

@ -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.
#