remove action for model in rails_admin
Asked Answered
M

3

7

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?

Mabe answered 11/7, 2012 at 12:20 Comment(1)
You have marked the answer as correct when it does not answer anything.Jeffry
D
21

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

Doehne answered 13/10, 2014 at 9:46 Comment(0)
O
1

try changing in the file: config/initilizers/rails_admin.rb you can comment out the actions that you don't want to allow!

Our answered 12/7, 2012 at 6:38 Comment(1)
tryed this, but it didnt helpMabe
D
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
Dracula answered 17/9, 2014 at 23:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.