Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Overview

Application Helper

Instance Method Summary collapse

Instance Method Details

#destroy_button(object) ⇒ Object


25
26
27
28
29
30
31
# File 'app/helpers/application_helper.rb', line 25

def destroy_button(object)
  link_to(t('.destroy'),
          object,
          method: :delete,
          class: 'button',
          data: { confirm: t('.confirm_destroy') })
end

#edit_button(object) ⇒ Object


33
34
35
# File 'app/helpers/application_helper.rb', line 33

def edit_button(object)
  link_to(t('.edit'), [:edit, object], class: 'button')
end

#index_button(object) ⇒ Object


37
38
39
# File 'app/helpers/application_helper.rb', line 37

def index_button(object)
  link_to(t('.index'), object.class, class: 'button')
end

#p_wrap(control_tags) ⇒ Object


11
12
13
14
15
# File 'app/helpers/application_helper.rb', line 11

def p_wrap(control_tags)
  control_tags.map do |control_tag|
    tag.p(class: 'control') { control_tag }
  end
end

#page_buttons(object) ⇒ Object


17
18
19
20
21
22
23
# File 'app/helpers/application_helper.rb', line 17

def page_buttons(object)
  buttons = []
  buttons << edit_button(object) if policy(object).edit?
  buttons << index_button(object)
  buttons << destroy_button(object) if policy(object).destroy?
  buttons
end

#show_page_buttons(object) ⇒ Object


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

def show_page_buttons(object)
  tag.div(class: 'field has-addons') do
    safe_join(p_wrap(page_buttons(object)))
  end
end