simplify children_of
This commit is contained in:
parent
61c22e6324
commit
1921661fad
1 changed files with 4 additions and 8 deletions
|
@ -155,15 +155,11 @@ class ProcedureRevision < ApplicationRecord
|
|||
end
|
||||
|
||||
def children_of(tdc)
|
||||
parent_revision_type_de_champ = revision_types_de_champ.find_by(type_de_champ: tdc)
|
||||
parent_coordinate_id = revision_types_de_champ.where(type_de_champ: tdc).select(:id)
|
||||
|
||||
if parent_revision_type_de_champ.present?
|
||||
types_de_champ
|
||||
.where(procedure_revision_types_de_champ: { parent_id: parent_revision_type_de_champ.id })
|
||||
.order("procedure_revision_types_de_champ.position")
|
||||
else
|
||||
TypeDeChamp.none
|
||||
end
|
||||
types_de_champ
|
||||
.where(procedure_revision_types_de_champ: { parent_id: parent_coordinate_id })
|
||||
.order("procedure_revision_types_de_champ.position")
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue