Activeadmin disabling the "new resource" method
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).
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, 2021Comments
-
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 over 12 yearsThat 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 over 12 yearsin the index menu adding "default_actions" works to get view/edit/delete actions
-
makaroni4 over 12 yearsI got this: undefined method `clear_action_items!' for #<ActiveAdmin::Application:0x00000103447628> (NoMethodError)
-
mbillard about 12 years
actions :index
did not work for me, butactions :all, :except => [:new]
did the job. -
Juanjo Conti almost 10 years@makaroni4 you have to call it inside the DSL.
-
danielricecodes about 7 yearsSmall 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 acontroller
block! -
Piers C almost 7 years
actions :index
oractions:all, :except ...
is recommended and documented.