Module: EacRailsUtils::LinksHelper

Defined in:
app/helpers/eac_rails_utils/links_helper.rb

Instance Method Summary collapse

Instance Method Details

#object_path(object, action = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/eac_rails_utils/links_helper.rb', line 35

def object_path(object, action = nil)
  current_class = object.class
  tried_paths = []
  while current_class
    path = object_path_by_class(current_class, action)
    return send(path, object) if respond_to?(path)
    tried_paths << path
    current_class = current_class.superclass
  end
  raise "Path not found for {object: #{object.class}, action: \"#{action}\"}" \
    "(Tried: #{tried_paths})"
end


4
5
6
7
8
9
10
11
12
# File 'app/helpers/eac_rails_utils/links_helper.rb', line 4

def short_delete_link(object)
  short_object_link object, '', class: 'delete_link', method: :delete, target: '_blank',
                                title: ::I18n.t('eac_rails_base0.links.delete_object',
                                                label: object.to_s),
                                data: {
                                  confirm: ::I18n.t('eac_rails_base0.links.delete_confirm',
                                                    label: object.to_s)
                                }
end


31
32
33
# File 'app/helpers/eac_rails_utils/links_helper.rb', line 31

def short_detail_link(object)
  short_detail_show_link(object, true)
end


14
15
16
17
18
# File 'app/helpers/eac_rails_utils/links_helper.rb', line 14

def short_edit_link(object)
  short_object_link object, 'edit', class: 'edit_link', target: '_blank',
                                    title: ::I18n.t('eac_rails_base0.links.edit_object',
                                                    label: object.to_s)
end


20
21
22
23
24
25
# File 'app/helpers/eac_rails_utils/links_helper.rb', line 20

def short_goto_link(url)
  value_or_sign(url, '') do |value|
    link_to '', value, class: 'goto_link', target: '_blank',
                       title: ::I18n.t('eac_rails_base0.links.goto_url', url: value.to_s)
  end
end


27
28
29
# File 'app/helpers/eac_rails_utils/links_helper.rb', line 27

def short_show_link(object)
  short_detail_show_link(object, false)
end