correctif(liens.invitations): utilise le mapping rails as: :target_model, sinon on requete uniquement par l'id du model, qui peut etre problématique en cas de relation polymorphiques avec des ensembles d'id se superposant

This commit is contained in:
Martin 2023-01-31 16:06:31 +01:00 committed by mfo
parent 4f4791a864
commit 2edfcdd652
2 changed files with 2 additions and 2 deletions

View file

@ -28,7 +28,7 @@ class Avis < ApplicationRecord
has_one :expert, through: :experts_procedure has_one :expert, through: :experts_procedure
has_one :procedure, through: :experts_procedure has_one :procedure, through: :experts_procedure
has_many :targeted_user_links, dependent: :destroy, inverse_of: :target_model, foreign_key: 'target_model_id' has_many :targeted_user_links, as: :target_model, dependent: :destroy, inverse_of: :target_model
FILE_MAX_SIZE = 20.megabytes FILE_MAX_SIZE = 20.megabytes
validates :piece_justificative_file, validates :piece_justificative_file,

View file

@ -16,7 +16,7 @@ class Invite < ApplicationRecord
belongs_to :dossier, optional: false belongs_to :dossier, optional: false
belongs_to :user, optional: true belongs_to :user, optional: true
has_one :targeted_user_link, dependent: :destroy, inverse_of: :target_model, foreign_key: 'target_model_id' has_one :targeted_user_link, as: :target_model, dependent: :destroy, inverse_of: :target_model
before_validation -> { sanitize_email(:email) } before_validation -> { sanitize_email(:email) }