ruby-on-railsruby-on-rails-4ruby-on-rails-5activeadminruby-on-rails-6

ActiveAdmin actions


is there a way to specify in ActiveAdmin's index page of a model what actions are allowed, things like:

index do
  actions :edit
end

index do
  actions only: :edit
end

do not work. What's the correct syntax?

Appreciated.

bundle show activeadmin
/home/muichkine/.rvm/gems/ruby-2.1.2/bundler/gems/active_admin-9cfc45330e5a

Solution

  • Add whatever actions you want to be available by using actions (it is usually put under model definition):

    ActiveAdmin.register YourModel do
      actions :index, :show, :create, :edit, :update
      # ...
    end
    

    If you want to specify the method for certain action, you can do

    action_item only: :show  do
      link_to 'Edit', action: :edit # so link will only be available on show action
    end