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.
- #posted? ⇒ Boolean
- #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
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 |
.submenu ⇒ Object
26 27 28 |
# File 'lib/forge/app/models/post.rb', line 26 def self. "posts" end |
Instance Method Details
#archive_link ⇒ Object
39 40 41 |
# File 'lib/forge/app/models/post.rb', line 39 def archive_link self.created_at.strftime("/posts/%m/%Y") end |
#archive_title ⇒ Object
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_list ⇒ Object
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 |
#next ⇒ Object
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
57 58 59 |
# File 'lib/forge/app/models/post.rb', line 57 def posted? self.published && self.created_at <= Time.now end |
#previous ⇒ Object
53 54 55 |
# File 'lib/forge/app/models/post.rb', line 53 def previous Post.where("created_at < ?", created_at)[0] end |
#to_param ⇒ Object
22 23 24 |
# File 'lib/forge/app/models/post.rb', line 22 def to_param "#{id}-#{title.parameterize}" end |