Module: LinkToAction::Helpers

Defined in:
lib/link_to_action/helpers.rb

Instance Method Summary collapse

Instance Method Details


35
36
37
# File 'lib/link_to_action/helpers.rb', line 35

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

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

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

12
13
14
# File 'lib/link_to_action/helpers.rb', line 12

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

8
9
10
# File 'lib/link_to_action/helpers.rb', line 8

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

4
5
6
# File 'lib/link_to_action/helpers.rb', line 4

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

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

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