Nihal Nizar
Nihal Nizar

Reputation: 165

Active Admin - Dropdown menu with same resources

I have a picture model and I want to know if it is possible for me to create a drop down menu where both resources are pictures with different names.

My picture model has an attribute 'gender', which can either be male or female.

I want to create the following structure

Picture
  ->Male
  ->Female

male.rb

ActiveAdmin.register Picture do
  menu parent: 'Pictures', :label => "Male"

female.rb

ActiveAdmin.register Picture do
  menu parent: 'Pictures', :label => "  female"

I changed the resource retrieval code also.

controller do
def scoped_collection
  end_of_association_chain.where(gender: 'M')
end
end

This is the menu structure that I get

Picture
  ->Male

Upvotes: 0

Views: 1517

Answers (1)

Timo Schilling
Timo Schilling

Reputation: 3073

This should help you:

ActiveAdmin.register Picture, as: "Male"
ActiveAdmin.register Picture, as: "Female"

Take a look at the related docs for details.

Upvotes: 0

Related Questions