This may not be a Breadcrumble question, but how do I pass a parameter from a previous plug into the breadcrumbable? For example, if the previous plug set_merchant
sets the merchant on conn.params.merchant
, how can I pass that id
to breadcrumable?
plug :set_merchant
plug :add_breadcrumb, name: "Dashboard", url: "/dashboard/#{conn.params.merchant_id}"
.....
defp set_merchant(conn, _opt) do
case conn.params do
%{"merchant_id" => merchant_id} ->
case MyApp.find_merchant(merchant_id) do
nil ->
conn |> redirect(to: "/dashboard/#{merchant_id}") |> halt
merchant ->
assign(conn, :merchant, merchant)
end
_ ->
conn |> redirect(to: "/") |> halt
end
end
The conn.params.merchant_id
is where I would want to pass the param from the first plug set_merchant