phoenix_live_view_example
phoenix_live_view_example copied to clipboard
Can't get phx_value_id on handle_event("delete_user", id, socket)
I've downloaded the example and did some tests. But when tried the action Delete at Presence Example I got the error:
[error] GenServer #PID<0.596.0> terminating
** (Ecto.Query.CastError) deps/ecto/lib/ecto/repo/queryable.ex:411: value `%{"altKey" => false, "ctrlKey" => false, "id" => "21", "metaKey" => false, "offsetX" => 108, "offsetY" => 27, "pageX" => 633, "pageY" => 752, "screenX" => 1378, "screenY" => 329, "shiftKey" => false, "x" => 633, "y" => 195}` in `where` cannot be cast to type :id in query:
Seems can't get phx_value_id at templates->user->index.html.leex. And I have changed at below then it worked.
def handle_event("delete_user", id, socket) do
#user = Accounts.get_user!(id)
user = Accounts.get_user!(id["id"])
{:ok, _user} = Accounts.delete_user(user)
{:noreply, socket}
end
Please help to review.
You are correct! This was fixed in #55