Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveAdmin - make resource index show 'edit' and 'delete' but not 'view'

I have a resource called Foobar, and on my /admin/foobars page I have a list of all foobars with the options view, edit, and delete appearing. I only want edit and delete to appear.

app/admin/foobars.rb

ActiveAdmin.register Foobar do
  index do
    # Here I have a bunch of columns for various fields in Foobar
    # default_actions #=> Uncommenting this line would make view, edit, and delete appear.
    actions :defaults => false do |foobar|
      link_to 'Edit', edit_admin_foobar_path(foobar)
      link_to 'Delete', admin_foobar_path(foobar), :method => :delete, :confirm => "Are you sure"
    end
  end
end

My problem is that this only shows the Delete option - Edit only shows up when I remove the second line. How do I get them to both show up under the same header?

like image 906
Kvass Avatar asked Oct 21 '25 02:10

Kvass


1 Answers

ActiveAdmin.register Foobar do


  index do
    ...
    column "" do |resource|
      links = ''.html_safe
      links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
      links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'), :class => "member_link delete_link"
      links
    end
  end
end

EDIT

Remove 'Show' link from ActiveAdmin default_actions

like image 116
rmagnum2002 Avatar answered Oct 25 '25 10:10

rmagnum2002