I have a problem. In my app I am using rails_admin gem. Everything is good except one thing. For some models I want to make possible only to delete them. Is there an easy way to do this?
Asked
Active
Viewed 6,859 times
6
-
You have marked the answer as correct when it does not answer anything. – Pedro Rolo Sep 03 '14 at 18:12
3 Answers
20
In your rails_admin.rb file, you can add the default actions for your models in wich you can add exceptions as shown here.
Here is an exemple :
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
Here is the link to the rails_admin documentation about actions : https://github.com/sferik/rails_admin/wiki/Actions
Community
- 1
- 1
Edmond Lafay-David
- 533
- 7
- 22
1
try changing in the file: config/initilizers/rails_admin.rb you can comment out the actions that you don't want to allow!
FedeX
- 426
- 2
- 8
0
You can do this using CanCan: https://github.com/sferik/rails_admin/wiki/Cancan
add this to your ability.rb file:
cannot :manage, Model # disable all actions for this model
can :destroy, Model # enable only to remove
ricardokrieg
- 733
- 8
- 11