我有一个名为Foobar
的资源,在我的/admin/foobars
页面上,我列出了包含view
,edit
和{{1}选项的所有foobar出现。我只希望delete
和edit
出现。
应用/管理/ 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
仅在我删除第二行时显示。如何将它们显示在相同的标题下?
答案 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
修改强>
答案 2 :(得分:0)
这是我的方式:
index do
actions do |resource|
(link_to 'link_1", url) + "\t|\t" +
(link_to 'link_2", url)
end
end
=>它在视图中生成:link_1 |链接2