Mark 1to1 nested relationships as update_only to avoid creating multiple associations

This fixes the invalid entreprises without etablissements
This commit is contained in:
Paul Chavard 2018-03-07 17:42:02 +01:00
parent d14c67c32b
commit d5f620a163
2 changed files with 2 additions and 2 deletions

View file

@ -6,7 +6,7 @@ class Entreprise < ApplicationRecord
validates :siren, presence: true
validates :dossier_id, uniqueness: true
accepts_nested_attributes_for :rna_information
accepts_nested_attributes_for :rna_information, update_only: true
before_save :default_values

View file

@ -5,7 +5,7 @@ class Etablissement < ApplicationRecord
has_many :exercices, dependent: :destroy
accepts_nested_attributes_for :exercices
accepts_nested_attributes_for :entreprise
accepts_nested_attributes_for :entreprise, update_only: true
validates :dossier_id, uniqueness: true