about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/blog.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/blog.rb b/app/models/blog.rb index 03643bf..8599bcd 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb
@@ -48,6 +48,14 @@ class Blog < ApplicationRecord
48 end 48 end
49 end 49 end
50 50
51 def prev
52 Blog.where(published: true).where("published_at < ?", published_at).order(published_at: :desc).first
53 end
54
55 def next
56 Blog.where(published: true).where("published_at > ?", published_at).order(published_at: :asc).first
57 end
58
51 private 59 private
52 def set_draft_title 60 def set_draft_title
53 if self.title.blank? and not self.published 61 if self.title.blank? and not self.published