Class: Post

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_at_dateObject

Scopes, Attachments, etc.



3
4
5
# File 'lib/forge/app/models/post.rb', line 3

def created_at_date
  @created_at_date
end

#created_at_timeObject

Scopes, Attachments, etc.



3
4
5
# File 'lib/forge/app/models/post.rb', line 3

def created_at_time
  @created_at_time
end

Class Method Details

.get_archive_monthsObject



43
44
45
46
# File 'lib/forge/app/models/post.rb', line 43

def self.get_archive_months
  posts = self.posted.all
  return posts.map{|p| {:title => p.archive_title, :link => p.archive_link} }.uniq
end


26
27
28
# File 'lib/forge/app/models/post.rb', line 26

def self.submenu
  "posts"
end

Instance Method Details



39
40
41
# File 'lib/forge/app/models/post.rb', line 39

def archive_link
  self.created_at.strftime("/posts/%m/%Y")
end

#archive_titleObject

Achive month handling



35
36
37
# File 'lib/forge/app/models/post.rb', line 35

def archive_title
  self.created_at.strftime("%B %Y")
end

#category_listObject



30
31
32
# File 'lib/forge/app/models/post.rb', line 30

def category_list
  self.post_categories.map { |c| "<a href='/posts/#{c.id}/category'>#{c.title}</a>" }.join(', ').html_safe
end

#nextObject

previous and next posts for mobile post nav



49
50
51
# File 'lib/forge/app/models/post.rb', line 49

def next
  Post.where("created_at > ?", created_at)[-1]
end

#posted?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/forge/app/models/post.rb', line 57

def posted?
  self.published && self.created_at <= Time.now
end

#previousObject



53
54
55
# File 'lib/forge/app/models/post.rb', line 53

def previous
  Post.where("created_at < ?", created_at)[0]
end

#to_paramObject



22
23
24
# File 'lib/forge/app/models/post.rb', line 22

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