Introduce scopes for finding bubbles assigned to or by someone
This commit is contained in:
@@ -6,6 +6,9 @@ module Bubble::Assignable
|
||||
|
||||
has_many :assignees, through: :assignments
|
||||
has_many :assigners, through: :assignments
|
||||
|
||||
scope :assigned_to, ->(user) { joins(:assignments).where(assignments: { assignee: user }) }
|
||||
scope :assigned_by, ->(user) { joins(:assignments).where(assignments: { assigner: user }) }
|
||||
end
|
||||
|
||||
def assign(users, assigner: Current.user)
|
||||
|
||||
@@ -8,7 +8,6 @@ class User < ApplicationRecord
|
||||
has_many :buckets, through: :accesses
|
||||
has_many :bubbles, through: :buckets
|
||||
|
||||
|
||||
has_many :assignments, foreign_key: :assignee_id, dependent: :destroy
|
||||
has_many :assignings, foreign_key: :assigner_id, class_name: "Assignment"
|
||||
has_many :assigned_bubbles, through: :assignments, source: :bubble
|
||||
|
||||
Reference in New Issue
Block a user