Method: Espresso::View::InstanceMethods#link_to_destroy

Defined in:
lib/espresso/view/inherited_resources.rb


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/espresso/view/inherited_resources.rb', line 45

def link_to_destroy(object=nil, path=nil)
  object ||= resource
  path ||= if object == resource
             resource_path
           else
             object
           end
  class_underscored = object.class.name.underscore
  link_to(t("helpers.action.#{class_underscored}.edit",
            :default => [:'helpers.action.destroy', 'Destroy']),
          path,
          :class => Espresso::View.block_classes('action', %w(destroy)),
          :method => :delete,
          :confirm => t("helpers.action.#{class_underscored}.confirm_destroy",
                        :default => [:'helpers.action.confirm_destroy', 'are you sure?']))
end