答案 0 :(得分:95)
您向actions
添加了对每个Active Admin资源的调用:
ActiveAdmin.register Foobar do
actions :all, :except => [:destroy]
end
答案 1 :(得分:7)
在某些时候我遇到了这个问题,因为破坏方法,“删除”按钮没有消失
actions :all, except: [:destroy]
controller do
def destroy # => Because of this the 'Delete' button was still there
@user = User.find_by_slug(params[:id])
super
end
end
答案 2 :(得分:2)
接受的答案引发了一个异常,“错误的参数数量”所以我这样做是为了排除删除按钮(:destroy action)
ActiveAdmin.register YourModel do
actions :index, :show, :new, :create, :update, :edit
index do
selectable_column
id_column
column :title
column :email
column :name
actions
end
答案 3 :(得分:1)
从{_1}}资源的default_actions中删除操作的另一种方法是通过ActiveAdmin
变量,例如:
config
在通过
ActiveAdmin.register MyUser do config.remove_action_item(:destroy) ... end
方法接受的答案中已经提到了一种方法。
答案 4 :(得分:0)
如果要删除完全删除销毁按钮,请使用: 行动:全部,除了:[:destroy]
但是如果删除按钮需要基于资源属性的条件(例如关联数据或状态)。
在索引页面: 索引做 ...... ...... actions默认值:false do | row | 如果能? :读,行 text_node link_to“View”,admin_resource_path(row),class:“view_link” 结束 如果能? :编辑,排 text_node link_to“编辑”,admin_resource_path(行),类:“edit_link” 结束 如果能? :破坏,排 text_node link_to I18n.t('active_admin.delete'),admin_resource_path(row),方法:: delete,data:{confirm:I18n.t('active_admin.delete_confirmation')},class:“delete_link”if row.deletable? 结束 端
端
现在复杂的部分,我不得不多次敲打我的头来控制它在显示页面:
config.remove_action_item(:destroy)#将删除销毁按钮
仅限action_item :: show do
link_to I18n.t('active_admin.delete'), admin_resource_path(resource), method: :delete, data: { confirm: I18n.t('active_admin.delete_confirmation') }, class: "delete_link" if resource.deletable?
端
抱歉我的格式糟糕。