From 593b087ba1edb8ac570e6d74c7abe4393875e235 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 23 Jul 2018 16:48:51 -0300 Subject: [PATCH] si no enviamos fecha hay que poner una por defecto --- app/models/post.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index e1449c7a..cca94777 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -413,6 +413,7 @@ class Post def cleanup! things_to_arrays! + default_date_is_today! date_to_time! clean_content! slugify_title! @@ -501,12 +502,17 @@ class Post @errors end + def default_date_is_today! + set_front_matter('date', Time.now) unless date + end + def date_to_time! unless @front_matter.dig(:date).is_a? Time @front_matter['date'] = @front_matter.dig('date').try(:to_time) || Time.now end end + # XXX es necesario ahora que tenemos select2? def things_to_arrays! [:tags,:categories].each do |c| thing = @front_matter.dig(c.to_s)