17

I've made a title of my resources as a link to a Show action. Now I want to remove that link form default_actions.

actions :all, :except => [:show]

Won't do because I need show action to be available.

I'le also tried

column do |show|
  links = ''.html_safe
  links += link_to "Edit", edit_admin_show_path(show)
  links += ' '
  links += link_to "Del", admin_show_path(show), :confirm => 'Are you sure?', :method => :delete
  links
end

But delete link isn't working but rather takes me to the Show page.

I'll be thankful for any help

Uko
  • 13,134
  • 6
  • 58
  • 106

2 Answers2

34

I did it this way (resource_path).

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
phuk
  • 1,098
  • 1
  • 10
  • 15
  • This was really helpful @pedro - I with an example like this was in the product documentation — one question, I'm trying to make a link that behaves remotely — any comment on how to get some javascript dumped in here that refers to the rows correctly? – MBHNYC Jul 17 '12 at 22:10
  • @MBHNYC what exactly are you trying to do? Make link which sends ajax request with row data? – phuk Jul 18 '12 at 14:56
  • Actually I got it, I was trying to add jQuery that modified the link after the remote success object came back, but it was far simpler just to run the task non-remotely and re-render the index page, so I did that. Thx! – MBHNYC Jul 18 '12 at 17:04
  • +1, just a minor thing, you dont even need to pass first empty string argument. – naveed Sep 24 '14 at 23:04
  • 1
    If you delete a registry and the JS confirmation pop-up doesn't show up, try replacing the fourth line with this : `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"` see [source code](https://github.com/activeadmin/activeadmin/blob/master/lib/active_admin/views/index_as_table.rb#L334) – nicosierra Apr 21 '15 at 01:40
22

More recent versions support a call to actions method within the resource definition:

ActiveAdmin.register Foo do
  actions :all, except: [:edit, :destroy] #just show
  ...
bdumtish
  • 416
  • 3
  • 5