demarches-normaliennes/app/models/groupe_instructeur.rb

16 lines
573 B
Ruby
Raw Normal View History

2019-08-19 16:12:30 +02:00
class GroupeInstructeur < ApplicationRecord
DEFAULT_LABEL = 'défaut'
belongs_to :procedure, -> { with_discarded }, inverse_of: :groupe_instructeurs
2019-08-20 16:47:41 +02:00
has_many :assign_tos
has_many :instructeurs, through: :assign_tos, dependent: :destroy
2019-08-22 17:58:31 +02:00
has_many :dossiers
2019-12-03 18:36:50 +01:00
has_and_belongs_to_many :exports
2019-10-09 18:05:43 +02:00
validates :label, presence: { message: 'doit être renseigné' }, allow_nil: false
validates :label, uniqueness: { scope: :procedure, message: 'existe déjà' }
before_validation -> { label&.strip! }
scope :without_group, -> (group) { where.not(id: group) }
2019-08-19 16:12:30 +02:00
end