Sha256: fa4bed71b79921af9b184a19aad8eccea10efbc28b0928e8678f391492c760cf

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

module MyForum
  module ApplicationHelper

    def draw_navigation
      html_li  = content_tag :li, link_to('Forums', root_path)

      if @forum
        html_li += content_tag :li, '→'.html_safe
        html_li += content_tag :li, link_to(@forum.name, forum_path(@forum))
      end

      if @forum && @topic && !@topic.new_record?
        html_li += content_tag :li, '→'.html_safe
        html_li += content_tag :li, link_to(@topic.name.html_safe, forum_topic_path(@forum, @topic))
      end

      html = content_tag :ul, class: 'draw-navigation' do
        html_li
      end

      html.html_safe
    end

    def online_users
      User.online.pluck(:login).join(', ')
    end

    def today_was_users
      User.today_visited.pluck(:login).join(', ')
    end

    def errors_for(obj)
      return if obj.errors.blank?

      content_tag :div, obj.errors.full_messages.to_sentence, class: 'errors_for'
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my_forum-0.0.1.beta1 app/helpers/my_forum/application_helper.rb