[英]remove action for model in rails_admin
我有個問題。 在我的應用程序中,我使用的是rails_admin gem。 除了一件事,一切都很好。 對於某些型號,我希望只刪除它們。 是否有捷徑可尋?
在你rails_admin.rb文件,你可以為你的模型中至極如圖所示,您可以添加例外添加默認的行為在這里 。
這是一個例子:
config.actions do
dashboard # mandatory
index # mandatory
new do
except ['SomeModel']
end
export
bulk_delete
show
edit do
except ['SomeOtherModel']
end
delete
show_in_app
end
以下是有關操作的rails_admin文檔的鏈接: https : //github.com/sferik/rails_admin/wiki/Actions
嘗試更改文件:config / initilizers / rails_admin.rb您可以注釋掉您不想允許的操作!
您可以使用CanCan執行此操作: https : //github.com/sferik/rails_admin/wiki/Cancan
將此添加到ability.rb文件中:
cannot :manage, Model # disable all actions for this model
can :destroy, Model # enable only to remove
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.