about summary refs log tree commit diff stats
path: root/app/models/blog.rb
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-11-05 20:32:13 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2023-11-05 20:32:13 -0500
commit65808633a2e0259b54cefb268ebf79418b49e67c (patch)
tree39336c2a9204dd0da317e915a09a15abd3c53bd7 /app/models/blog.rb
parentb047d1c54fb86742490b3bece574c2b84eb17f99 (diff)
downloadthoughts-65808633a2e0259b54cefb268ebf79418b49e67c.tar.gz
thoughts-65808633a2e0259b54cefb268ebf79418b49e67c.tar.bz2
thoughts-65808633a2e0259b54cefb268ebf79418b49e67c.zip
Added forward and back links to blog posts
Diffstat (limited to 'app/models/blog.rb')
-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