si no enviamos fecha hay que poner una por defecto

This commit is contained in:
f 2018-07-23 16:48:51 -03:00
parent 0dc9d1d157
commit 593b087ba1
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7

View file

@ -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)