Class: Blog::Gem::Post

Inherits:
ApplicationRecord show all
Includes:
PgSearch
Defined in:
app/models/blog/gem/post.rb

Instance Method Summary collapse

Instance Method Details

#author_nameObject



22
23
24
25
26
# File 'app/models/blog/gem/post.rb', line 22

def author_name
  if author.present? && show_author
    author.name
  end
end

#categoryObject



44
45
46
47
48
49
50
51
# File 'app/models/blog/gem/post.rb', line 44

def category
  if category_id.present?
    category = Blog::Gem.categories.index(category_id)
    {name: category.humanize, link: "#{Blog::Gem.path}/category/#{category}"}
  else
    {name: "<i>#{I18n.t("blog.no_category")}</i>", link: Blog::Gem.path}
  end
end

#image_url(type = :medium) ⇒ Object



28
29
30
# File 'app/models/blog/gem/post.rb', line 28

def image_url(type=:medium)
  "#{Blog::Gem.url}#{thumbnail.url(type)}"
end

#tagsObject



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

def tags
  tag_list.join(", ")
end

#to_pathObject



32
33
34
# File 'app/models/blog/gem/post.rb', line 32

def to_path
  "#{Blog::Gem.path}/#{url}"
end

#to_urlObject



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

def to_url
  "#{Blog::Gem.url}#{to_path}"
end