Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !2212

Add correct hyperlinks on nested models in collections

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/paulRbr/link-nested-models-in-collections into main Jun 14, 2022
  • Overview 8
  • Commits 3
  • Pipelines 0
  • Changes 6

Created by: paulRbr

Context

E.g. In the following routes, Order model can only be shown (or edited) when it's accessed via it's nested /customers/:customer_id/orders route. If we imagine order ids to be dependent of customers (Order#1 for Customer#1 and Order#1 for Customer#2):

Rails.application.routes.draw do
  namespace(:admin) do
    resources :customers do
      resources :orders, only: [:show, :edit]
    end
  end
end

Until now, administrate would not link the associated models in collections when their actions can only work correctly with the existence of a parent resource (by defining a Admin::OrdersController#find_resource method to find the nested resource depending on URL params).

Suggestion

This PR tries to allow models which are nested within a parent related model to be accessed via a nested URL.

I'm not 100% happy with the current codebase (it has lots of duplication) but I wanted to share the main idea which works for us @bump-sh.

Please let me know if this feature could see life in Administrate and how I can make this suggestion better? Thanks!

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/paulRbr/link-nested-models-in-collections