models: explicitly mark optional belongs_to
relationship as so
This prepares making the `belongs_to` relationship required by default.
This commit is contained in:
parent
31dfdbf993
commit
11456109c0
9 changed files with 14 additions and 14 deletions
|
@ -18,7 +18,7 @@ class Avis < ApplicationRecord
|
|||
include EmailSanitizableConcern
|
||||
|
||||
belongs_to :dossier, inverse_of: :avis, touch: true
|
||||
belongs_to :instructeur
|
||||
belongs_to :instructeur, optional: true
|
||||
belongs_to :claimant, class_name: 'Instructeur'
|
||||
|
||||
has_one_attached :piece_justificative_file
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
class Champ < ApplicationRecord
|
||||
belongs_to :dossier, -> { with_discarded }, inverse_of: :champs, touch: true
|
||||
belongs_to :type_de_champ, inverse_of: :champ
|
||||
belongs_to :parent, class_name: 'Champ'
|
||||
belongs_to :parent, class_name: 'Champ', optional: true
|
||||
has_many :commentaires
|
||||
has_one_attached :piece_justificative_file
|
||||
|
||||
# We declare champ specific relationships (Champs::CarteChamp, Champs::SiretChamp and Champs::RepetitionChamp)
|
||||
# here because otherwise we can't easily use includes in our queries.
|
||||
has_many :geo_areas, dependent: :destroy
|
||||
belongs_to :etablissement, dependent: :destroy
|
||||
belongs_to :etablissement, optional: true, dependent: :destroy
|
||||
has_many :champs, -> { ordered }, foreign_key: :parent_id, inverse_of: :parent, dependent: :destroy
|
||||
|
||||
delegate :libelle,
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
class Commentaire < ApplicationRecord
|
||||
belongs_to :dossier, inverse_of: :commentaires, touch: true
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :instructeur
|
||||
belongs_to :user, optional: true
|
||||
belongs_to :instructeur, optional: true
|
||||
|
||||
validate :messagerie_available?, on: :create
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# entreprise_id :integer
|
||||
#
|
||||
class Etablissement < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
belongs_to :dossier, optional: true
|
||||
|
||||
has_one :champ, class_name: 'Champs::SiretChamp'
|
||||
has_many :exercices, dependent: :destroy
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# user_id :integer
|
||||
#
|
||||
class FranceConnectInformation < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :user, optional: true
|
||||
|
||||
validates :france_connect_particulier_id, presence: true, allow_blank: false, allow_nil: false
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ class Invite < ApplicationRecord
|
|||
include EmailSanitizableConcern
|
||||
|
||||
belongs_to :dossier
|
||||
belongs_to :user
|
||||
belongs_to :user, optional: true
|
||||
|
||||
before_validation -> { sanitize_email(:email) }
|
||||
|
||||
|
|
|
@ -66,9 +66,9 @@ class Procedure < ApplicationRecord
|
|||
has_one :module_api_carto, dependent: :destroy
|
||||
has_one :attestation_template, dependent: :destroy
|
||||
|
||||
belongs_to :parent_procedure, class_name: 'Procedure'
|
||||
belongs_to :canonical_procedure, class_name: 'Procedure'
|
||||
belongs_to :service
|
||||
belongs_to :parent_procedure, class_name: 'Procedure', optional: true
|
||||
belongs_to :canonical_procedure, class_name: 'Procedure', optional: true
|
||||
belongs_to :service, optional: true
|
||||
|
||||
def active_revision
|
||||
brouillon? ? draft_revision : published_revision
|
||||
|
|
|
@ -52,7 +52,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
belongs_to :procedure
|
||||
belongs_to :revision, class_name: 'ProcedureRevision', optional: true
|
||||
|
||||
belongs_to :parent, class_name: 'TypeDeChamp'
|
||||
belongs_to :parent, class_name: 'TypeDeChamp', optional: true
|
||||
has_many :types_de_champ, -> { ordered }, foreign_key: :parent_id, class_name: 'TypeDeChamp', inverse_of: :parent, dependent: :destroy
|
||||
|
||||
store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles, :old_pj, :drop_down_options, :skip_pj_validation
|
||||
|
|
|
@ -45,8 +45,8 @@ class User < ApplicationRecord
|
|||
has_many :dossiers_invites, through: :invites, source: :dossier
|
||||
has_many :feedbacks, dependent: :destroy
|
||||
has_one :france_connect_information, dependent: :destroy
|
||||
belongs_to :instructeur
|
||||
belongs_to :administrateur
|
||||
belongs_to :instructeur, optional: true
|
||||
belongs_to :administrateur, optional: true
|
||||
|
||||
accepts_nested_attributes_for :france_connect_information
|
||||
|
||||
|
|
Loading…
Reference in a new issue