Elixir 未为实现协议EXTO.Queryable

Elixir 未为实现协议EXTO.Queryable,elixir,phoenix-framework,ecto,Elixir,Phoenix Framework,Ecto,我正在尝试将Guardian实现到我的API中,并通过它进行登录以获取JWT。我正在看的教程是。问题是使用与示例中使用的用户模型类似的用户模型来实现登录。模型代码如下所示: defmodule PushflightServer.User do use PushflightServer.Web, :model use Ecto.Repo import Ecto.Query alias PushflightServer.Repo schema "users" do field

我正在尝试将Guardian实现到我的API中,并通过它进行登录以获取JWT。我正在看的教程是。问题是使用与示例中使用的用户模型类似的用户模型来实现登录。模型代码如下所示:

defmodule PushflightServer.User do
  use PushflightServer.Web, :model

use Ecto.Repo
import Ecto.Query
  alias PushflightServer.Repo

  schema "users" do
    field :name, :string
    field :email, :string
    field :encrypted_password, :string
    field :password, :string, virtual: true
    field :verify_token, :string
    field :verify_date, Ecto.DateTime

    timestamps
  end

  def from_email(nil), do: { :error, :not_found }
  def from_email(email) do
    IO.write("Before email")
    IO.inspect(email)
    Repo.one(User, email: email)
  end
如果我从Phoenix内部或直接在iex-S mix中调用from_电子邮件,我会得到以下错误:

user=PushflightServer.user.from_电子邮件(“rob@json.com))

**(Protocol.UndefinedError)Protocol-exto.Queryable未为用户实现,给定模块不存在 (exto)lib/exto/queryable.ex:33:exto.queryable.Atom.to_query/1 (exto)lib/exto/repo/queryable.ex:90:exto.repo.queryable.execute/5 (exto)lib/exto/repo/queryable.ex:15:exto.repo.queryable.all/4 (exto)lib/exto/repo/queryable.ex:44:exto.repo.queryable.one/4


我肯定错过了一些简单的东西,但我还没有找到任何关于为什么会发生这种情况的文档。使用回购协议插入数据效果良好。有什么想法吗?

您需要将
User
完全命名为
PushflightServer.User
,或者您可以使用快捷方式
\uuuuu模块

您应该引用具有名称空间的模块

  def from_email(email) do
    PushflightServer.one(PushflightServer.User, email: email)
  end