Add graph loading scopes to Dossier and Procedure

This commit is contained in:
Paul Chavard 2018-11-19 20:55:24 +01:00
parent 7f09d0e430
commit 2e854f2ac3
2 changed files with 7 additions and 0 deletions

View file

@ -163,6 +163,9 @@ class Dossier < ApplicationRecord
}
scope :for_procedure, -> (procedure) { includes(:user, :groupe_instructeur).where(groupe_instructeurs: { procedure: procedure }) }
scope :for_api_v2, -> {
includes(procedure: [:administrateurs], etablissement: [], individual: [])
}
accepts_nested_attributes_for :individual

View file

@ -62,6 +62,10 @@ class Procedure < ApplicationRecord
accepte: 'accepte'
}
scope :for_api_v2, -> {
includes(administrateurs: :user)
}
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :description, presence: true, allow_blank: false, allow_nil: false
validates :administrateurs, presence: true