0

In rails 6, I am using activeadmin gem for admin interface.

My code is like,

ActiveAdmin.register Account, as: "Individual Accounts" do
  menu parent: "Accounts", label: "Individual Accounts"
  permit_params :first_name, :last_name, :email, :password, :role_id

  filter :first_name
  filter :email

  index do
    selectable_column
    column :first_name
    column :last_name
    column "Role" do |acc|
      acc.role
    end
    column :email
    actions
  end

  form do |f|
    f.inputs do
      f.input :first_name
      f.input :last_name
      f.input :email
      f.input :password
    end
    f.actions
  end

  show do
    attributes_table do
      row :role
      row :first_name
      row :last_name
      row :email
    end
  end

  controller do
    after_create :set_account_type

    def set_account_type resource
      resource.type = "EmailAccount"
      role = RolesPermissions::Role.find_by(name:"Individual")
      resource.role_id = role.id
      resource.save
    end
    def create
      super do |success,failure|
        success.html { redirect_to admin_individual_accounts_path }
      end
    end
  end
  controller do 
    def scoped_collection
       Account.joins(:role).where(roles: {name: "Individual"})
    end
  end
end

I want to remove New Individual Accounts button(option) from the page. If I try to override an action_item like as mentioned below then one more button will get add

action_item only: :new do
  link_to 'Add New', new_admin_individual_account_path
end

Please help me to remove new option.

Shruthi R
  • 1,863
  • 4
  • 39
  • 77
  • According the the [Docs](https://rubydoc.info/gems/activeadmin/ActiveAdmin/Views/IndexAsTable) it appears you can pass `default: false` to `actions` which will: *"forego the default links entirely:"* it seems you can also use `actions :all, except: [:create]`. This [SO Post](https://stackoverflow.com/questions/25727623/activeadmin-actions) might help you figure out the direction you want to go – engineersmnky Jan 27 '23 at 18:20

1 Answers1

0

go to the routes file and add the to remove the new route -> except: [:new]

mas
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 24 '23 at 12:58