In my router I currently have the following:
resources "/customer_common_tasks", CustomerCommonTasksController
In the CustomerCommonTasksController
lives the following update
function:
def update(conn, %{"id" => id, "customer_common_tasks" => customer_common_tasks_params}) do
customer_common_tasks = Customer.get_customer_common_tasks!(id)
with {:ok, %CustomerCommonTasks{} = customer_common_tasks} <- Customer.update_customer_common_tasks(customer_common_tasks, customer_common_tasks_params) do
render(conn, "show.json", customer_common_tasks: customer_common_tasks)
end
end
When I send a PUT
request to the endpoint I get back an ActionClauseError
as if there was no route to the update function, however when I run mix phx.routes
I can see it exists:
PUT /api/customer_common_tasks/:id myApp.CustomerCommonTasksController :update
The logger notes that my request carries the following params:
14:04:39.342 request_id=2mli8bmgvp03ormudk00008h remote_ip=ip [debug] Processing with MyApp.CustomerCommonTasksController.update/2
Parameters: %{"customer_common_task" => %{"belongs_to" => nil, "name" => "A Task", "notes" => "some notes", "customer_id" => nil, "resolved" => true}, "id" => "13"}
But when even if I use a function with a header of (connm, _params)
I can’t get the function to trigger.
I’m not sure where I have gone wrong here and any advice would be greatly appreciated