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



41
42
43
44
# File 'lib/forge/app/models/post.rb', line 41

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


24
25
26
# File 'lib/forge/app/models/post.rb', line 24

def self.submenu
  "posts"
end

Instance Method Details



37
38
39
# File 'lib/forge/app/models/post.rb', line 37

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

#archive_titleObject

Achive month handling



33
34
35
# File 'lib/forge/app/models/post.rb', line 33

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

#category_listObject



28
29
30
# File 'lib/forge/app/models/post.rb', line 28

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



47
48
49
# File 'lib/forge/app/models/post.rb', line 47

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

#previousObject



51
52
53
# File 'lib/forge/app/models/post.rb', line 51

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

#to_paramObject



20
21
22
# File 'lib/forge/app/models/post.rb', line 20

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