Reputation: 26061
I want to show the link in the show view of ActiveAdmin. But it should not show up in the grid of the index view. I can't figure out how to do this. I've already tried quite a few approaches.
actions :all, except: proc{ params['id'].present? ? [:new, :destroy] : [:new, :destroy, :edit] }.call
this fails with undefined local variable or method 'params'
actions :all, only: :show, except: [:new, :destroy, :edit]
action_item only: :show do
link_to 'Edit Cash Out', "/admin/documents/#{params['id']}/edit" if params['id']
end
this fails because the route isn't being created for the edit path
actions :all, except: [:new, :destroy].tap do |a|
a << :edit unless params['id'].present?
end
fails with no block given
Upvotes: 0
Views: 1048
Reputation: 7361
Can you please try below code?
actions :all, only: :show, except: [:new, :destroy, :edit]
action_item :view, only: :show do
link_to 'Edit Cash Out', "/admin/documents/#{params['id']}/edit" if params['id']
end
Upvotes: 2
Reputation: 710
If I am not mistaken, you only want to hide the link to the edit action in the index page (in the grid).
If this is correct, one possible solution is included in this answer:
index do
column :actions do |item|
links = []
links << link_to('Show', show_item_path)
links << link_to('Delete', delete_item_path, method: :delete, confirm: 'Are you sure?')
links.join(' ').html_safe
end
end
Just keep in mind to adjust the aforementioned code to fit the routes and naming.
Hope this works for you.
Upvotes: 2