Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#section(title, options = {}, &block) ⇒ Object


24
25
26
27
# File 'app/helpers/application_helper.rb', line 24

def section(title, options = {}, &block)
  options[:class] = Array(options[:class]) << 'row-fluid'
  render 'section', title: title, options: options, contents: capture(&block)
end

#sortable(column, title = nil) ⇒ Object


6
7
8
9
10
11
# File 'app/helpers/application_helper.rb', line 6

def sortable(column, title = nil)
  title ||= column.titleize
  css_class = column == sort_column ? "current #{sort_direction}" : nil
  direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
  link_to title, { sort: column, direction: direction, q: params[:q] },  class: css_class
end

#state_label(state) ⇒ Object


13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/application_helper.rb', line 13

def state_label(state)
  css = case state.downcase
        when 'processing'; then 'warning'
        when 'onhold'; then 'inverse'
        when 'success'; then 'success'
        when 'failed'; then 'important'
        else 'default'
        end
  (:span, class: "label label-#{css}") { state.capitalize }
end

#title(string) ⇒ Object


2
3
4
# File 'app/helpers/application_helper.rb', line 2

def title(string)
  content_for(:title) { string }
end