Ruby 更改ActiveAdmin删除方法
我正在为网站创建凭证系统,我不想授予管理员删除凭证的权利,我只想将我的字段状态从启用更新为禁用,而不是删除链接。您可以选择所需的操作,然后创建“禁用”成员操作:Ruby 更改ActiveAdmin删除方法,ruby,activeadmin,Ruby,Activeadmin,我正在为网站创建凭证系统,我不想授予管理员删除凭证的权利,我只想将我的字段状态从启用更新为禁用,而不是删除链接。您可以选择所需的操作,然后创建“禁用”成员操作: ActiveAdmin.register Voucher do actions :all, except: [:destroy] member_action :disable, :method => :put do voucher = Voucher.find(params[:id]) voucher.u
ActiveAdmin.register Voucher do
actions :all, except: [:destroy]
member_action :disable, :method => :put do
voucher = Voucher.find(params[:id])
voucher.update_attribute!(:status, "disabled")
end
action_item only: [:show] do
unless voucher.status == "disabled"
link_to("Disable", disable_admin_voucher_path(voucher), method: 'put')
end
end
end