开发者

Compilation error in file and undefined function

I'm compiling the phoenix application and I run into error on one of my module.

def toggle_complete(conn, %{"id" => id} = _params, _current_user, _claims) do
    with %Payout{} <- payout = Repo.get(Payout, id),
         {_count, nil} <- Payouts.toggle_prize_claims(payout),
         {:ok, payout} <- Payouts.toggle_complete(payout) do
      conn |> render("payout_simple.json", payout: payout)
    else
      nil -> {:error, :payout_not_found}
      error -> error
    end
end

Following is the error

== Compilation error in file lib/pxf/web/controllers/mart/payout_controller.ex ==
** (CompileError) lib/pxf/web/controller开发者_运维问答s/mart/payout_controller.ex:145: undefined function payout/0 (expected Pxf.Web.Mart.PayoutController to define such a function or for it to be imported, but none are available)

I'm not sure why it is showing undefined function. Am I doing something wrong for the pattern matching here?


You should assign payout in your scope.

- with %Payout{} <- payout = Repo.get(Payout, id)
+ with %Payout{} = payout <- Repo.get(Payout, id)

with/1 declares its own scope and applies a hygiene to RHOs of <-. That means the assignment in the RHO got simply discarded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜