Class: Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Post
- Defined in:
- app/models/post.rb
Constant Summary collapse
- @@per_page =
10
Instance Method Summary collapse
- #has_images? ⇒ Boolean
- #live? ⇒ Boolean
- #preview_image ⇒ Object
- #rendered_body ⇒ Object
- #rendered_preview ⇒ Object
- #to_param ⇒ Object
Instance Method Details
#has_images? ⇒ Boolean
48 49 50 |
# File 'app/models/post.rb', line 48 def has_images? images && !images.empty? end |
#live? ⇒ Boolean
53 54 55 |
# File 'app/models/post.rb', line 53 def live? live && live == true end |
#preview_image ⇒ Object
44 45 46 |
# File 'app/models/post.rb', line 44 def preview_image images.first if has_images? end |
#rendered_body ⇒ Object
40 41 42 |
# File 'app/models/post.rb', line 40 def rendered_body render(body.gsub("<!-- more -->", "")) end |
#rendered_preview ⇒ Object
35 36 37 38 |
# File 'app/models/post.rb', line 35 def rendered_preview preview = body.split("<!-- more -->")[0] render(preview) end |
#to_param ⇒ Object
57 58 59 |
# File 'app/models/post.rb', line 57 def to_param path end |