[#3424] Improve formatting of addresses with missing components

This commit is contained in:
Frederic Merizen 2019-02-13 09:57:33 +01:00
parent 8750d0e410
commit 41ab7246cf
2 changed files with 11 additions and 1 deletions

View file

@ -45,7 +45,11 @@ class Etablissement < ApplicationRecord
def inline_adresse
# squeeze needed because of space in excess in the data
"#{numero_voie} #{type_voie} #{nom_voie}, #{complement_adresse}, #{code_postal} #{localite}".squeeze(' ')
[
"#{numero_voie} #{type_voie} #{nom_voie}",
complement_adresse,
"#{code_postal} #{localite}"
].map { |s| s.squeeze(' ') }.reject(&:blank?).join(', ')
end
def verify