diff --git a/app/models/champ.rb b/app/models/champ.rb index 49023ac09..c884a0b08 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -67,14 +67,7 @@ class Champ < ApplicationRecord def to_s if value.present? - case type_champ - when 'date' - Date.parse(value).strftime('%d/%m/%Y') - when 'multiple_drop_down_list' - drop_down_list.selected_options_without_decorator(self).join(', ') - else - value.to_s - end + string_value else '' end @@ -118,4 +111,10 @@ class Champ < ApplicationRecord errors end + + private + + def string_value + value.to_s + end end diff --git a/app/models/champs/date_champ.rb b/app/models/champs/date_champ.rb index 93eb983c4..310f608a9 100644 --- a/app/models/champs/date_champ.rb +++ b/app/models/champs/date_champ.rb @@ -11,4 +11,8 @@ class Champs::DateChamp < Champ nil end end + + def string_value + Date.parse(value).strftime('%d/%m/%Y') + end end diff --git a/app/models/champs/multiple_drop_down_list_champ.rb b/app/models/champs/multiple_drop_down_list_champ.rb index 77ce7f2b8..9054dc48c 100644 --- a/app/models/champs/multiple_drop_down_list_champ.rb +++ b/app/models/champs/multiple_drop_down_list_champ.rb @@ -14,4 +14,8 @@ class Champs::MultipleDropDownListChamp < Champ end end end + + def string_value + drop_down_list.selected_options_without_decorator(self).join(', ') + end end