3

我有一个名为 的资源Foobar,在我的页面上,我有一个包含选项、和出现/admin/foobars的所有 foobar 的列表。我只想和出现。vieweditdeleteeditdelete

应用程序/管理员/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

我的问题是这仅显示Delete选项 -Edit仅在我删除第二行时显示。如何让它们都出现在同一个标​​题下?

4

3 回答 3

6
ActiveAdmin.register Foobar do
  actions :all, except: [:view]
  ...
end
于 2014-01-13T02:43:06.857 回答
5
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

编辑

从 ActiveAdmin default_actions 中删除“显示”链接

于 2013-07-16T20:13:33.977 回答
0

这是我的方式:

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

=> 它在视图中产生:link_1 | 链接 2

于 2015-08-10T02:52:49.527 回答