Module: LinkToAction::Helpers

Defined in:
lib/link_to_action/helpers.rb

Instance Method Summary collapse

Instance Method Details



37
38
39
# File 'lib/link_to_action/helpers.rb', line 37

def link_to_back(options = {})
  link_to_action :back, nil, options
end


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/link_to_action/helpers.rb', line 18

def link_to_destroy(object, options = {})
  options[:method] = :delete
  if (options.has_key? :confirm)
    confirm = options.delete(:confirm)
  else
    confirm = LinkToAction.destroy_confirm
  end
  if confirm
    if confirm.kind_of?(String)
      confirm_text = confirm
    else
      confirm_text = t(:'helpers.link_to.destroy_confirm')
    end
    options[:data] = { :confirm => confirm_text }
  end
  options['data-skip-pjax'] = true if LinkToAction.destroy_skip_pjax
  link_to_action(:destroy, object, options)
end


14
15
16
# File 'lib/link_to_action/helpers.rb', line 14

def link_to_edit(object, options = {})
  link_to_action(:edit, object, options)
end


10
11
12
# File 'lib/link_to_action/helpers.rb', line 10

def link_to_index(object, options = {})
  link_to_action(:index, object, options)
end


6
7
8
# File 'lib/link_to_action/helpers.rb', line 6

def link_to_new(object, options = {})
  link_to_action(:new, object, options)
end


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/link_to_action/helpers.rb', line 41

def link_to_show(object, options = {})
  name = options.delete(:name)
  raw = options.delete(:raw)
  send = options.delete(:send)
  i18n = options.delete(:i18n)
  unless name or i18n
    method = raw || send ||
      LinkToAction.show_methods.find { |m| object.respond_to?(m) }
    name = object.send(method)
    name = raw(name) if raw
  end
  
  if i18n
    options[:name] = name
    link_to_action :show, object, options
  else
    link_to name, object, options
  end
end