in rails gem active admin我想從default_actions中刪除刪除選項,而我仍然需要編輯和顯示操作,有沒有辦法做到這一點?如何刪除activeAdmin的刪除選項?
38
A
回答
86
您調用actions
添加到每個主動管理資源:
ActiveAdmin.register Foobar do
actions :all, :except => [:destroy]
end
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
0
接受的答案拋出異常,「錯誤的參數數目」,所以我這樣做是爲了排除刪除按鈕(:破壞行動)
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
0
如果要刪除刪除按鈕完全使用: 操作:除:[:destroy]
但是,如果刪除按鈕需要基於資源屬性的條件(例如,相關數據或狀態)。
在索引頁: 指數做 ...... ...... 行動的默認值:假做|行| 如果可以? :第 text_node link_to「查看」,admin_resource_path(row) :編輯,行 text_node link_to「編輯」,admin_resource_path(row),class:「edit_link」 end if can? :destroy,row text_node link_to I18n.t('active_admin.delete'),admin_resource_path(row),method :: delete,data:{confirm:I18n.t('active_admin.delete_confirmation')},class:「delete_link」如果row.deletable? 結束 結束
末
現在複雜的部分,我不得不一聲我的頭幾次在節目頁面來控制它:
config.remove_action_item(:銷燬)#將刪除銷燬按鈕
action_item只:節目做
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?
末
對不起,我可怕的格式。
相關問題
- 1. 刪除ActiveAdmin資源
- 2. 刪除選項
- 3. 刪除選項
- 4. 如何刪除項目刪除時的「,」?
- 5. 如何刪除空的選擇選項?
- 6. 如何刪除/刪除scss/compass項目?
- 7. 更改ActiveAdmin刪除方法
- 8. ActiveAdmin Rails編輯/刪除
- 9. 刪除gridview選項
- 10. 陷阱刪除項刪除
- 11. Opencart的 - 刪除選項值
- 12. 刪除選中的項目
- 13. NVD3 - 刪除stackedAreaChart的選項
- 14. 的GridView與刪除選項
- 15. jQuery刪除設置選擇選項選擇不刪除
- 16. jQuery的刪除選項除了當前
- 17. 如何從ckeditor刪除表格選項
- 18. 如何從TabItem中刪除選項卡?
- 19. jqGrid:如何刪除編輯選項?
- 20. 刪除listview項只刪除第一項
- 21. ActiveAdmin&Rails 3:刪除用戶時如何刪除用戶相關數據?
- 22. 選擇選項後刪除ColdFusion選項
- 23. javascript/jquery從選擇中刪除或刪除選項
- 24. ModelChoiceField,刪除空白選項
- 25. 從tabPanel刪除選項卡
- 26. 刪除導航選項kibana
- 27. Drupal 6 | Flexifields刪除選項
- 28. 刪除JQuery UI選項卡
- 29. nvd3刪除流選項
- 30. 從SharedPreferences刪除ListView選項