Good morning,
Starting out with Phoenix and Elixir and we are having issues with the online tutorial when using Ecto with Phoenix V1.3.2.
We've setup the application with the following
mix phx.new api --no-brunch --no-html --database=mysql
Following the tutorial we get to using Ecto, however we've read that there's some breaking changes but cannot figure out the reason for the below error.
** (exit) an exception was raised: ** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for Api.User, the given module does not exist. This protocol is implemented for: Atom, BitString, Ecto.Query, Ecto.SubQuery, Tuple
Here is some example code for one of our controllers which gets invoked fine (api/lib/api_web/v1/controllers
defmodule ApiWeb.AuthenticationController do
use ApiWeb, :controller
def auth(conn, %{"username" => username, "password" => password}) do
json conn, Api.Repo.all(Api.User) # ??
end
end
and our Ecto Schema here generated by mix.gen.model (api/web/models)
defmodule Api.User do
use Api.Web, :model
schema "users" do
field :username, :string
field :display_name, :string
field :password, :binary
field :api_key, :binary
field :api_expiry, :naive_datetime
field :company, :string
field :email, :string
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:username, :display_name, :password, :api_key, :api_expiry, :company, :email])
|> validate_required([:username, :display_name, :password, :api_key, :api_expiry, :company, :email])
end
end
We have not ventured too far into the Elixir & Phoenix world hence there is no business logic, simply following the online tutorial for now.
Thanks in advance,