Activeadmin disabling the "new resource" method

24,641

Solution 1

Try config.clear_action_items! to remove the link to New and other links on top of the table

Solution 2

Previous solution didn`t work for me, so here is general solutions, that works always:

ActiveAdmin.register Book do
  actions :index

  #or like that
  #actions :all, :except => [:destroy]

  index do
    column :title
    column :author
  end  
end

Solution 3

This removed the "New Resource" button from the top-right:

    config.clear_action_items!

This removed both the "New Resource" button as well as the box "There are no resources yet - create one".

    actions :all, :except => [:new]

Thank you, Irio

Solution 4

config.clear_action_items!

Will remove all the actions. If you only want to remove the new action link you can also use:

config.remove_action_item(:new)

Solution 5

I know this is an old question, but I just came up to it (had the same problem), and realized that config.clear_action_items! and actions :all, :except => [:new] are fundamentally different.

config.clear_action_items! will remove the New button from the index page, while actions :all, :except => [:new] will remove both the button, AND the route, meaning you can't call it from another place (which, in my case, is needed).

Share:
24,641
YuKagi
Author by

YuKagi

I really enjoy Objective-C, iOS, Ruby, and Ruby on Rails development. I study as hard and fast as I can. I really appreciate everyone's help and understanding. Thank you.

Updated on August 05, 2021

Comments

  • YuKagi
    YuKagi almost 3 years

    I'm using Activeadmin for the admin interface on an app I'm working on (loving it) and I am curious if there is a way to disable the "New Resource" link in the upper-right corner of the resource show page?

    The particular resource I'm using is nested inside another resource and I have a partial that allows it to be created from the show page on that parent resource.

    I have disabled the resource in the menu, but I'd rather leave the resource in the menu so I can see/edit/delete those resources without having to find it by looking through its parent resource.

  • YuKagi
    YuKagi over 12 years
    That right there did it. Thank you very much. In the event that I want to have items in the action menu, do I just add them after I clear it?
  • makvool
    makvool over 12 years
    in the index menu adding "default_actions" works to get view/edit/delete actions
  • makaroni4
    makaroni4 over 12 years
    I got this: undefined method `clear_action_items!' for #<ActiveAdmin::Application:0x00000103447628> (NoMethodError)
  • mbillard
    mbillard about 12 years
    actions :index did not work for me, but actions :all, :except => [:new] did the job.
  • Juanjo Conti
    Juanjo Conti almost 10 years
    @makaroni4 you have to call it inside the DSL.
  • danielricecodes
    danielricecodes about 7 years
    Small note here. If you define a custom controller and define new inside of the controller block, that will override this setting. Just learned that one. If you specify that a certain action shouldn't exist, ensure you do not also define it in a controller block!
  • Piers C
    Piers C almost 7 years
    actions :index or actions:all, :except ... is recommended and documented.