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)