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!