I see the default action_items in the resource_controller class, but can't figure out how to disable them via the active_admin model config. Is that possible?
# Default Action Item Links
action_item :only => :show do
if controller.action_methods.include?('edit')
link_to("Edit #{active_admin_config.resource_name}", edit_resource_path(resource))
end
end
action_item :only => :show do
if controller.action_methods.include?("destroy")
link_to("Delete #{active_admin_config.resource_name}",
resource_path(resource),
:method => :delete, :confirm => "Are you sure you want to delete this?")
end
end
action_item :except => [:new, :show] do
if controller.action_methods.include?('new')
link_to("New #{active_admin_config.resource_name}", new_resource_path)
end
end
-Ryan
Nevermind. I see how you can open up the controller in the config like this:
ActiveAdmin.register User do
controller do
actions :all, :except => [:edit, :destroy]
end
end
Thanks.
Do you want to only disable the buttons? Or the entire actions?
To disable the actions use:
actions :index, :show
Or
actions :except => [:edit, :update]
Currently there is no supported mechanism to turn on and off individual action items that you didn't create.
On 2011-05-31, at 7:41 AM, ryanwoodreply@reply.github.com wrote:
I see the default action_items in the resource_controller class, but can't figure out how to disable them via the active_admin model config. Is that possible?
# Default Action Item Links
action_item :only => :show do
if controller.action_methods.include?('edit')
link_to("Edit #{active_admin_config.resource_name}", edit_resource_path(resource))
end
endaction_item :only => :show do
if controller.action_methods.include?("destroy")
link_to("Delete #{active_admin_config.resource_name}",
resource_path(resource),
:method => :delete, :confirm => "Are you sure you want to delete this?")
end
endaction_item :except => [:new, :show] do
if controller.action_methods.include?('new')
link_to("New #{active_admin_config.resource_name}", new_resource_path)
end
end-Ryan
Reply to this email directly or view it on GitHub:
https://github.com/gregbell/active_admin/issues/134
@ryanwood No need to open the controller class, you can call #actions directly from the registration block
And what if you need only to remove the buttons because you are using a belongs_to association of Inherited Resources?
Most helpful comment
Nevermind. I see how you can open up the controller in the config like this:
Thanks.