Class: Tenon::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Tenon::Post
- Defined in:
- app/models/tenon/post.rb
Instance Method Summary collapse
-
#next ⇒ Object
previous and next posts for mobile post nav.
- #posted? ⇒ Boolean
- #previous ⇒ Object
- #to_param ⇒ Object
Instance Method Details
#next ⇒ Object
previous and next posts for mobile post nav
23 24 25 |
# File 'app/models/tenon/post.rb', line 23 def next Post.posted.where('publish_at > ?', publish_at).last end |
#posted? ⇒ Boolean
31 32 33 |
# File 'app/models/tenon/post.rb', line 31 def posted? publish_at.present? ? publish_at <= Time.now : false end |
#previous ⇒ Object
27 28 29 |
# File 'app/models/tenon/post.rb', line 27 def previous Post.posted.where('publish_at < ?', publish_at).first end |
#to_param ⇒ Object
18 19 20 |
# File 'app/models/tenon/post.rb', line 18 def to_param "#{id}-#{title.parameterize}" end |