models: fix touch not propagating when using nested attributes
Sometimes, when using nested attributes, touch doesn’t propagate to parent relationships. (see https://github.com/rails/rails/issues/26726) Specifically, this happens in our app when updating a dossier with only new attachements (but without changing the value of any fields). To work around this, we need to define the parent relationship explicitely. This is good practice anyway. Fix #3906
This commit is contained in:
parent
52d672486e
commit
51aacabf13
7 changed files with 57 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
class Champ < ApplicationRecord
|
||||
belongs_to :dossier, touch: true
|
||||
belongs_to :dossier, inverse_of: :champs, touch: true
|
||||
belongs_to :type_de_champ, inverse_of: :champ
|
||||
belongs_to :parent, class_name: 'Champ'
|
||||
has_many :commentaires
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue