Module: Formol::ApplicationHelper
- Defined in:
- app/helpers/formol/application_helper.rb
Instance Method Summary collapse
- #breadcrumb_for(record) ⇒ Object
-
#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).
Instance Method Details
#breadcrumb_for(record) ⇒ Object
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 (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 content_tag(:ul, :class => 'breadcrumb') do items.each do |(text, path)| concat(content_tag(: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 |