Class: ActiveAdmin::Views::IndexAsTable::IndexTableFor

Inherits:
Object
  • Object
show all
Defined in:
lib/active_admin/cancan_integration.rb

Instance Method Summary collapse

Instance Method Details

#default_actions(options = {}) ⇒ Object

lib/active_admin/views/index_as_table.rb



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_admin/cancan_integration.rb', line 22

def default_actions(options = {})
  options = {
    :name => ""
  }.merge(options)
  column options[:name] do |resource|
    links = ''.html_safe
    if controller.action_methods.include?('show') && can?(:read, resource)
      links += link_to I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link"
    end
    if controller.action_methods.include?('edit') && can?(:update, resource)
      links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
    end
    if controller.action_methods.include?('destroy') && can?(:destroy, resource)
      links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :data => {:confirm => I18n.t('active_admin.delete_confirmation')}, :class => "member_link delete_link"
    end
    links += yield(resource) if block_given?
    links 
  end
end