Class: Post

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

Constant Summary collapse

@@per_page =
10

Instance Method Summary collapse

Instance Method Details

#has_images?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/models/post.rb', line 48

def has_images?
  images && !images.empty?
end

#live?Boolean

Returns:

  • (Boolean)


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

def live?
  live && live == true
end

#preview_imageObject



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

def preview_image
   images.first if has_images?	  
end

#rendered_bodyObject



40
41
42
# File 'app/models/post.rb', line 40

def rendered_body
 render(body.gsub("<!-- more -->", ""))
end

#rendered_previewObject



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

def rendered_preview
  preview = body.split("<!-- more -->")[0]
  render(preview)
end

#to_paramObject



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

def to_param
	path
end