champ: return the parent dossier even when discarded
Dossier has a `default_scope { kept }`. Because of that, when the parent dossier is discarded, `champ.dossier` will return nil. We should kill the default scope. But meanwhile, ensure that `champ.dossier` returns even a discarded dossier.
This commit is contained in:
parent
76ce622ebf
commit
1cb18e51ac
2 changed files with 12 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
class Champ < ApplicationRecord
|
||||
belongs_to :dossier, inverse_of: :champs, touch: true
|
||||
belongs_to :dossier, -> { with_discarded }, 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