ActiveAdmin - 使资源索引显示“编辑”和“删除”但不显示“查看”

时间:2013-07-16 17:29:46

标签: ruby-on-rails-3 activeadmin

我有一个名为Foobar的资源,在我的/admin/foobars页面上,我列出了包含viewedit和{{1}选项的所有foobar出现。我只希望deleteedit出现。

应用/管理/ foobars.rb

delete

我的问题是,这只显示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仅在我删除第二行时显示。如何将它们显示在相同的标题下?

3 个答案:

答案 0 :(得分:6)

ActiveAdmin.register Foobar do
  actions :all, except: [:view]
  ...
end

答案 1 :(得分: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

修改

Remove 'Show' link from ActiveAdmin default_actions

答案 2 :(得分:0)

这是我的方式:

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

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