Class: Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Post
- Defined in:
- lib/forge/app/models/post.rb
Instance Attribute Summary collapse
-
#created_at_date ⇒ Object
Scopes, Attachments, etc.
-
#created_at_time ⇒ Object
Scopes, Attachments, etc.
Class Method Summary collapse
Instance Method Summary collapse
- #archive_link ⇒ Object
-
#archive_title ⇒ Object
Achive month handling.
- #category_list ⇒ Object
-
#next ⇒ Object
previous and next posts for mobile post nav.
- #previous ⇒ Object
- #to_param ⇒ Object
Instance Attribute Details
#created_at_date ⇒ Object
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_time ⇒ Object
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_months ⇒ Object
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 |
.submenu ⇒ Object
24 25 26 |
# File 'lib/forge/app/models/post.rb', line 24 def self. "posts" end |
Instance Method Details
#archive_link ⇒ Object
37 38 39 |
# File 'lib/forge/app/models/post.rb', line 37 def archive_link self.created_at.strftime("/posts/%m/%Y") end |
#archive_title ⇒ Object
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_list ⇒ Object
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 |
#next ⇒ Object
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 |
#previous ⇒ Object
51 52 53 |
# File 'lib/forge/app/models/post.rb', line 51 def previous Post.where("created_at < ?", created_at)[0] end |
#to_param ⇒ Object
20 21 22 |
# File 'lib/forge/app/models/post.rb', line 20 def to_param "#{id}-#{title.parameterize}" end |