demarches-normaliennes/app/models/champs/date_champ.rb
gregoirenovel 7cd50531cf Remove the proxy string_value method
Overload to_s instead
2019-01-08 12:32:26 +01:00

22 lines
404 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class Champs::DateChamp < Champ
before_save :format_before_save
def search_terms
# Text search is pretty useless for dates so were not including these champs
end
def to_s
value.present? ? Date.parse(value).strftime('%d/%m/%Y') : ""
end
private
def format_before_save
self.value =
begin
Date.parse(value).iso8601
rescue
nil
end
end
end