Epigene
Epigene

Reputation: 3928

Rails Admin actions in model

I have a sensitive civic involvement Rails app. In it's Rails Admin I have disabled the delete and bulk_delete actions. In rails_admin.rb I have something like

RailsAdmin.config do |config|
  config.actions do
    dashboard                     # mandatory
    index                         # mandatory
    new
    export
    show
    edit
    # delete
    # bulk_delete
  end
end

How can I override this behaviour for specific models, for example, SitePosts? I have tried using the "rails_admin do" block in the model, but it is not working obviously.

rails_admin do
  configure :site_post do
    actions do
      new
      show
      edit
      delete
    end
  end
end

Upvotes: 0

Views: 1920

Answers (1)

slothbear
slothbear

Reputation: 2056

You can use the only method for enabling actions for specific models. For instance, in your rails_admin.rb:

config.actions do
  dashboard                     # mandatory
  index                         # mandatory
  new
  delete do
    only SitePost
  end
end

The only and except methods are documented in the wiki under Base action.

Upvotes: 2

Related Questions