Reputation: 8434
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?
Upvotes: 4
Views: 5525
Reputation: 458
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
Upvotes: 0
Reputation: 1014
ActiveAdmin.register Foobar do
actions :all, except: [:view]
...
end
Upvotes: 6
Reputation: 11421
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
Upvotes: 6