#Error during api creation

20 messages · Page 1 of 1 (latest)

elfin nova
#
protocol Ecto.Queryable not implemented for Todo.User of type Atom, the given module does not exist. This protocol is implemented for the following type(s): Atom, BitString, Ecto.Query, Ecto.SubQuery, Tuple```
I have this error and I can't solve it, here is the error and the code
```elixir
defmodule TodoWeb.UserController do
  use TodoWeb, :controller

  def index(conn, _params) do
    users = Todo.Repo.all(Todo.User)
    render(conn, "index.json", users: users)
  end

end
#

Error during api creation

atomic ember
#

Is there Todo.User module defined?

elfin nova
atomic ember
#

So how Todo.Repo.all(Todo.User) is supposed to know what to do?

elfin nova
atomic ember
#

Ok, but how is repo supposed to know what table to query if you do not define schema for your query?

#

You need to define Todo.User module that will describe schema you want

elfin nova
atomic ember
#

Where you want/need

elfin nova
atomic ember
#

In my case? lib/<my_app>/<context>/<schema_name>.ex in most cases, but it highly depends. In your case I would start with some Phoenix tutorial if you do not understand that. See #getting-started for list of learning materials

elfin nova
#

Ok, I thinks it's good

#

But I have this error that corresponds to what?

#

no function clause matching in TodoWeb.UserController.create/2

atomic ember
#

You have no function TodoWeb.UserController.create/2

#

I highly suggest reading some tutorial

elfin nova
elfin nova
atomic ember
#

Ok, so there is, but it do not match