Class: Tenon::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/tenon/post.rb

Instance Method Summary collapse

Instance Method Details

#nextObject

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

Returns:

  • (Boolean)


31
32
33
# File 'app/models/tenon/post.rb', line 31

def posted?
  publish_at.present? ? publish_at <= Time.now : false
end

#previousObject



27
28
29
# File 'app/models/tenon/post.rb', line 27

def previous
  Post.posted.where('publish_at < ?', publish_at).first
end

#to_paramObject



18
19
20
# File 'app/models/tenon/post.rb', line 18

def to_param
  "#{id}-#{title.parameterize}"
end