Module: Formol::ApplicationHelper

Defined in:
app/helpers/formol/application_helper.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/formol/application_helper.rb', line 3

def breadcrumb_for(record)
  items = [[t('home'), root_path]]
  
  klass = record.class.to_s
  
  case klass
    when 'Formol::Category'
      items << [record.label, category_path(record)]
    when 'Formol::Forum'
      items << [record.category.label, category_path(record.category)]
      items << [record.label, forum_path(record)]
    when 'Formol::Topic'
      items << [record.forum.category.label, category_path(record.forum.category)]
      items << [record.forum.label, forum_path(record.forum)]
      items << [record.title, forum_topic_path(record.forum, record)]
  end
  
  (:ul, :class => 'breadcrumb') do
    items.each do |(text, path)|
      concat((:li, :class => 'item'){ link_to(text, path) })
    end
  end
end

#link_to_last_post(forum, topic, post, text = nil) ⇒ Object

When you want to link to last post, you don’t need to calculate position of last post (wich need to load all topic’s posts). Last post is obviously on last page, you can rely then on posts_count in topic object



31
32
33
# File 'app/helpers/formol/application_helper.rb', line 31

def link_to_last_post(forum, topic, post, text = nil)
  link_to (text || '>'), last_page_forum_topic_path(forum, topic, post), :title => t('formol.posts.last_post.go_to_last')
end