Make user in Task model optional to support old database entries

This commit is contained in:
Patrick Gansterer 2020-10-10 20:39:40 +02:00
parent 78c4ebcb4b
commit beaca7d384

View file

@ -4,7 +4,7 @@ class Task < ApplicationRecord
has_many :users, :through => :assignments has_many :users, :through => :assignments
belongs_to :workgroup, optional: true belongs_to :workgroup, optional: true
belongs_to :periodic_task_group, optional: true belongs_to :periodic_task_group, optional: true
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id' belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id', optional: true
scope :non_group, -> { where(workgroup_id: nil, done: false) } scope :non_group, -> { where(workgroup_id: nil, done: false) }
scope :done, -> { where(done: true) } scope :done, -> { where(done: true) }