[Rails] ActiveAdmin - belongs_to

Tags
Rails
Engineering
Created
Nov 1, 2023 03:29 AM
Edited
Oct 31, 2023
Description
To nest the resource within another, you can use the belongs_to method
ActiveAdmin.register Project
ActiveAdmin.register Ticket do
  belongs_to :project
end
 
You can also use sidebar
ActiveAdmin.register Project do

  sidebar "Project Details", only: [:show, :edit] do
    ul do
      li link_to "Tickets",    admin_project_tickets_path(resource)
      li link_to "Milestones", admin_project_milestones_path(resource)
    end
  end
end

ActiveAdmin.register Ticket do
  belongs_to :project
end

ActiveAdmin.register Milestone do
  belongs_to :project
end

Source