Guardianを自分のAPIに実装しようとしていて、JWTを取得するためにログインを実行しようとしています。私が見ているチュートリアルはhereです。問題は、この例で使用しているのと同様のユーザーモデルを使用してログインを実装することです。モデルのコードは次のようになります。プロトコルEcto.Queryableが実装されていません
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
私はをミックスIEX -S フェニックス内またはストレートのいずれかからFROM_EMAILを呼び出す場合、私は次のエラーを取得する:
ユーザー= PushflightServer.User.from_email (「[email protected]」)
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for User, the given module does not exist (ecto) lib/ecto/queryable.ex:33: Ecto.Queryable.Atom.to_query/1 (ecto) lib/ecto/repo/queryable.ex:90: Ecto.Repo.Queryable.execute/5 (ecto) lib/ecto/repo/queryable.ex:15: Ecto.Repo.Queryable.all/4 (ecto) lib/ecto/repo/queryable.ex:44: Ecto.Repo.Queryable.one/4
私は、単純な何かが欠けする必要がありますが、私はこれが起こっている理由について任意のドキュメントを見つけることができませんでした。 Repoを使用したデータの挿入は正常に機能しました。何か案は?