Sha256: fff502da39ec69c0e55b004001c5f71f7be448dd95ba292c88ed8a24ace16a6e

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

module Sal
  module ApplicationHelper
    def errors_bar(*entities)
      entities = Array(entities)

      if entities.detect { |entity| entity.errors.any? }
        content_tag :div, 'Please correct the highlighted fields.', class: 'alert alert-danger'
      end
    end

    def messages_bar
      if notice
        content_tag :div, notice.html_safe, class: 'alert alert-success'
      elsif alert
        content_tag :div, alert.html_safe, class: 'alert alert-warning'
      end
    end

    def menu_item(item, tag = :li)
      options = section == item ? {class: 'active'} : {}
      content_tag tag, options do
        yield
      end
    end

    private

    def section
      content_for(:menu) ? content_for(:menu).strip.downcase : request.params[:controller]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sal-engine-0.0.2 app/helpers/sal/application_helper.rb
sal-engine-0.0.1 app/helpers/sal/application_helper.rb