Custom create action in ActiveAdmin

Viewed 1298

I am trying to add a custom create button in show page. I want only one create button in index page. I only want new button in show page alongside edit and delete.

ActiveAdmin.register User do
  permit_params :full_name, :email, :user_roles_id, :password, :password_confirmation

  action_item :create do
    link_to("New User", new_admin_user_path(@users), class: :button)
  end

  show do
    attributes_table do
      row :full_name
      row :email
      row :role do |user|
        auto_link user.user_role
      end
    end
  end
end

I am getting two create buttons in index page for my model. It is also showing create new button in form as well. I want to remove create new button in form.

Is there any inherit solution like showing all actions in show page for all models from active_admin config file?

1 Answers

Try to restrict your custom button to appear on show only with this:

action_item :create, only: :show do

And disable default create action with this:

actions :all, except: [:create]
Related