From 6370365fe430a93de1794513604bc555689b4b14 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Apr 2018 12:11:17 +0200 Subject: [PATCH] Task: parse individual_date --- lib/tasks/2018_04_03_type_individual_date.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/tasks/2018_04_03_type_individual_date.rake diff --git a/lib/tasks/2018_04_03_type_individual_date.rake b/lib/tasks/2018_04_03_type_individual_date.rake new file mode 100644 index 000000000..b9af6d731 --- /dev/null +++ b/lib/tasks/2018_04_03_type_individual_date.rake @@ -0,0 +1,14 @@ +namespace :'2018_04_03_type_individual_date' do + task set: :environment do + Individual.all.each { |individual| save_birthdate_in_datetime_format(individual) } + end + + def save_birthdate_in_datetime_format(individual) + if individual.birthdate.present? + begin + individual.update_column(:second_birthdate, Date.parse(individual.birthdate)) + rescue + end + end + end +end