我正在为网站创建一个凭证系统,我不想让管理员有权删除凭证,而不是删除链接我只想将我的字段状态从启用更新为禁用。 / p>
答案 0 :(得分:1)
你可以挑选你想要的动作,然后创建一个“禁用”成员动作:
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