Method: EntriesHelper#post_link

Defined in:
app/helpers/entries_helper.rb

#post_link(entity, text = entity&.title, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/entries_helper.rb', line 41

def post_link(entity, text = entity&.title, options = {})
  if entity.class.to_s == Post.to_s
    if entity..class.to_s == .to_s
      parameters = { category_slug: entity..slug, slug: entity.slug }
      link_to text, post_in_category_posts_path(parameters)
    else
      text
    end
  elsif entity.class.to_s == News.to_s
    parameters = { category_slug: entity.news_category&.slug, slug: entity.slug }
    if entity.news_category.nil?
      text
    else
      if entity.regional?
        link_to text, news_in_category_regional_news_index_path(parameters), options
      else
        link_to text, news_in_category_news_index_path(parameters), options
      end
    end
  else
    '—'
  end
end