hi
I am new to elixir. i used phx.gen.json to create curd create, index, show are working fine but update is not working at all
here is a code and error
controller
[code]def update(conn, %{“id” => id, “employee” => employee_params}) do
employee = Management.get_employee!(id)
with {:ok, %Employee{} = employee} <- Management.update_employee(employee, employee_params) do
render(conn, "show.json", employee: employee)
end
end[/code]
model
schema "employees" do
field :age, :integer
field :fullname, :string
field :status, :integer
timestamps()
end
@doc false
def changeset(%Employee{} = employee, attrs) do
employee
|> cast(attrs, [:fullname, :age, :status])
|> validate_required([:fullname, :age, :status])
end
end
Values i tried
‘{‘employee’=>{‘age’=>‘35’,‘fullname’=>‘ih’,‘status’=>‘1’}}’
‘{‘employee’:{‘age’:‘35’,‘fullname’:‘ih’,‘status’:‘1’}}’
{‘age’:‘35’,‘fullname’:‘ih’,‘status’:‘1’}
{‘age’=>‘35’,‘fullname’=>‘ih’,‘status’=>‘1’}
%{“age” => “35”, “fullname” => “ih”, “id” => “2”, “status” => “1”}
error
Phoenix.ActionClauseError at PUT /api/employees/2
could not find a matching corpWeb.EmployeeController.update clause to process request. This typically happens when there is a parameter mismatch but may also happen when any of the other action arguments do not match. The request parameters are: