update draft timestamps with every edit

This commit is contained in:
Sami Samhuri 2015-04-19 21:54:32 -07:00
parent a136608ede
commit f54e5f12e5
2 changed files with 3 additions and 2 deletions

View file

@ -114,10 +114,11 @@ class HarpBlog
end
end
def update_post(post, title, body, link)
def update_post(post, title, body, link, timestamp = nil)
post.title = title
post.body = body
post.link = link
post.timestamp = timestamp if timestamp
save_post('update post', post)
end

View file

@ -220,7 +220,7 @@ put '/posts/drafts/:id' do |id|
title, body, link = @fields.values_at('title', 'body', 'link')
begin
if post = blog.get_draft(id)
blog.update_post(post, title, body, link)
blog.update_post(post, title, body, link, Time.now.to_i)
status 204
else
status 404