4

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?

Kvass
  • 8,294
  • 12
  • 65
  • 108

3 Answers3

6
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

Community
  • 1
  • 1
rmagnum2002
  • 11,341
  • 8
  • 49
  • 86
  • does that disable the show page altogether? I want the show page available, just not the view link in the index action set. I know it's a strange request, but... – Kvass Jul 16 '13 at 20:44
  • found it.. relly poor documentation on ActiveAdmin, but still a good plugin. – rmagnum2002 Jul 16 '13 at 21:17
  • yes, the documentation is absolutely terrible. I really hope they get their act together on that front before they release 1.0. I guess you can't complain when you're still using 0.wtvr. – Kvass Jul 16 '13 at 21:59
  • I ended up using the same `actions` block I already had, but using the link syntax you posted as its interior. – Kvass Jul 16 '13 at 22:03
  • If the pop-up doesn't work for the delete action try using this line instead: `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"` extracted from the [source code](https://github.com/activeadmin/activeadmin/blob/master/lib/active_admin/views/index_as_table.rb#L334) – nicosierra Apr 21 '15 at 01:37
6
ActiveAdmin.register Foobar do
  actions :all, except: [:view]
  ...
end
Skiptomylu
  • 964
  • 1
  • 13
  • 21
0

here is my way:

index do  
  actions do |resource|
     (link_to 'link_1", url)  + "\t|\t" +
     (link_to 'link_2", url)
  end
end

=> it produces in views : link_1 | link 2

Hai Nguyen
  • 458
  • 9
  • 15