Remove the proxy string_value method
Overload to_s instead
This commit is contained in:
parent
9a2341c56c
commit
7cd50531cf
4 changed files with 13 additions and 17 deletions
|
@ -41,7 +41,7 @@ class Champ < ApplicationRecord
|
|||
|
||||
def to_s
|
||||
if value.present?
|
||||
string_value
|
||||
value.to_s
|
||||
else
|
||||
''
|
||||
end
|
||||
|
@ -61,10 +61,6 @@ class Champ < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def string_value
|
||||
value.to_s
|
||||
end
|
||||
|
||||
def value_for_export
|
||||
value
|
||||
end
|
||||
|
|
|
@ -5,6 +5,10 @@ class Champs::DateChamp < Champ
|
|||
# Text search is pretty useless for dates so we’re not including these champs
|
||||
end
|
||||
|
||||
def to_s
|
||||
value.present? ? Date.parse(value).strftime('%d/%m/%Y') : ""
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def format_before_save
|
||||
|
@ -15,8 +19,4 @@ class Champs::DateChamp < Champ
|
|||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def string_value
|
||||
Date.parse(value).strftime('%d/%m/%Y')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,10 @@ class Champs::LinkedDropDownListChamp < Champ
|
|||
:primary_value
|
||||
end
|
||||
|
||||
def to_s
|
||||
value.present? ? [primary_value, secondary_value].compact.join(' / ') : ""
|
||||
end
|
||||
|
||||
def mandatory_and_blank?
|
||||
mandatory? && (primary_value.blank? || secondary_value.blank?)
|
||||
end
|
||||
|
@ -39,10 +43,6 @@ class Champs::LinkedDropDownListChamp < Champ
|
|||
|
||||
private
|
||||
|
||||
def string_value
|
||||
[primary_value, secondary_value].compact.join(' / ')
|
||||
end
|
||||
|
||||
def value_for_export
|
||||
"#{primary_value || ''};#{secondary_value || ''}"
|
||||
end
|
||||
|
|
|
@ -9,6 +9,10 @@ class Champs::MultipleDropDownListChamp < Champ
|
|||
value.blank? ? [] : JSON.parse(value)
|
||||
end
|
||||
|
||||
def to_s
|
||||
value.present? ? selected_options.join(', ') : ''
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def format_before_save
|
||||
|
@ -23,10 +27,6 @@ class Champs::MultipleDropDownListChamp < Champ
|
|||
end
|
||||
end
|
||||
|
||||
def string_value
|
||||
selected_options.join(', ')
|
||||
end
|
||||
|
||||
def value_for_export
|
||||
selected_options.join(', ')
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue