When nesting resources Phoenix changes param names.
The following example shows a param called slug which is renamed stuff_slug while it’s exactly the same param.
scope "/x/", MyAppWeb do
pipe_through [:browser, :protected]
get "/", OuterController, :index do
resources "/stuff", StuffController, as: :thing, param: "slug" do
patch "/publish", InnerController, :update, as: :publish
end
end
end
mix phx.routes
outer_path GET /x MyAppWeb.OuterController :index
thing_path GET /x/stuff MyAppWeb.StuffController :index
thing_path GET /x/stuff/:slug/edit MyAppWeb.StuffController :edit
thing_path GET /x/stuff/new MyAppWeb.StuffController :new
thing_path GET /x/stuff/:slug MyAppWeb.StuffController :show
thing_path POST /x/stuff MyAppWeb.StuffController :create
thing_path PATCH /x/stuff/:slug MyAppWeb.StuffController :update
PUT /x/stuff/:slug MyAppWeb.StuffController :update
thing_path DELETE /x/stuff/:slug MyAppWeb.StuffController :delete
thing_publish_path PATCH /x/stuff/:stuff_slug/publish MyAppWeb.InnerController :update
How should Phoenix.Router be instructed to produce the following result:
thing_publish_path PATCH /x/stuff/:slug/publish MyAppWeb.InnerController :update
Thank you.