我在 resource_controller 类中看到了默认的 action_items,但不知道如何通过 active_admin 模型配置禁用它们。 那可能吗?
# 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
-瑞安
没关系。 我看到了如何在配置中打开控制器,如下所示:
ActiveAdmin.register User do
controller do
actions :all, :except => [:edit, :destroy]
end
end
谢谢。
您只想禁用按钮吗? 还是整个动作?
要禁用这些操作,请使用:
动作:索引,:显示
或者
动作 :except => [:edit, :update]
目前没有支持的机制来打开和关闭您未创建的单个操作项。
2011 年 5 月 31 日上午 7 点 41 分, [email protected]写道:
我在 resource_controller 类中看到了默认的 action_items,但不知道如何通过 active_admin 模型配置禁用它们。 那可能吗?
# 默认操作项链接
action_item :only => :show do
if controller.action_methods.include?('edit')
link_to("编辑 #{active_admin_config.resource_name}", edit_resource_path(resource))
结尾
结尾action_item :only => :show do
if controller.action_methods.include?("destroy")
link_to("删除#{active_admin_config.resource_name}",
资源路径(资源),
:method => :delete, :confirm => "你确定要删除这个吗?")
结尾
结尾action_item :except => [:new, :show] 做
if controller.action_methods.include?('new')
link_to("新 #{active_admin_config.resource_name}", new_resource_path)
结尾
结尾-瑞安
直接回复此邮件或在 GitHub 上查看:
https://github.com/gregbell/active_admin/issues/134
@ryanwood不需要打开控制器类,可以直接从注册块调用#actions
如果您只需要删除按钮,因为您使用的是继承资源的 belongs_to 关联,该怎么办?
最有用的评论
没关系。 我看到了如何在配置中打开控制器,如下所示:
谢谢。