Mr H
Mr H

Reputation: 5304

Custom Route issue in Phoenix

Here is my route

scope "/api/v1", Web do
    pipe_through :api

    resources "/assets", AssetController do
      get "/descendants", AssetController, :descendants, as: :descendants
    end  
end

When I do:

iex(1)> import Web.Router.Helpers
Web.Router.Helpers
iex(2)> alias Web.Endpoint
Web.Endpoint
iex(3)> asset_path(Endpoint, :index)
"/api/v1/assets"
iex(4)> asset_descendants_path(Endpoint, :descendants)
** (CompileError) iex:4: undefined function asset_descendants_path/2

There is an error with asset_descendants_path(Endpoint, :descendants)

Here is the > mix routes

asset_descendants_path  GET     /api/v1/assets/:asset_id/descendants  Web.AssetController :descendants

Upvotes: 1

Views: 166

Answers (1)

Allen
Allen

Reputation: 834

Looks like you're missing the asset_id. You'll need to pass that in.

Upvotes: 3

Related Questions